Questions tagged [asp.net-mvc]

The ASP.NET MVC Framework stands out as a remarkable web application framework and tooling, based on open source concepts. It successfully incorporates a personalized variation of the model-view-controller (MVC) design pattern, specifically designed for creating and enhancing web applications. All this is made possible by building upon a solid foundation rooted in the innovative ASP.NET technology.

Encountering a surprise token < while processing JSON with ASP.NET MVC alongside Angular

I encountered an issue when attempting to return the Index page. The data is successfully sent from the client to the server, but upon trying to display the Index page, an error occurs. Could someone review my code and identify where the mistake lies? acc ...

Unlock the Power of Core 2 MVC with the Cutting-edge Integration of

Looking for a solution on how to effectively use JQuery Datatables with Core MVC? Check out this helpful resource: Using jQuery DataTables Grid With ASP.NET CORE MVC I recently downloaded the sample project and made some modifications to fit my needs. It ...

Using Javascript to fill a Telerik MVC combobox with data sourced from an array

My project is built on MVC4 and I am attempting to populate a Telerik MVC using JSON. The result should be an array, but currently, I am only receiving one item. Below is the script I am using: function CheckWord() { var wordToCheck = $('#Cword' ...

Combining ASP.NET MVC with HTML5 for dynamic web development

We are in the process of planning a new project and are interested in utilizing ASP.NET with the MVC pattern. Additionally, we want to incorporate the new features of HTML5. However, we have been having trouble finding sufficient information or connecting ...

Combining JsonResult and delivering a unified outcome in C#

I am looking to merge multiple JsonResults into a single named list for use in angularJS. Here is the function I have been working with: List<AdminBundle> abundleList = new List<AdminBundle>(); aBundleFetch.ListType = Constants.Board; Func< ...

Upon loading the page, trigger the controller method by utilizing the information from the query string

Can query string data be retrieved on page load with javascript? Here is how I am attempting to achieve this in my project: The view page displays tabular data. When a button is pressed, it retrieves the row's id and invokes a javascript function. Th ...

Reverting back to PDF using jQuery

I am currently utilizing jQuery to send JSON data back to the server, which in turn generates a PDF report. However, I am facing an issue where the PDF is not downloading despite specifying the necessary response header and including JavaScript as shown ...

Verify if an item is already present in the HTML document before adding a new item to it using Ajax

I am working on a page that displays a list of new students with the option to accept or reject them. The list can be updated in two ways - by manually refreshing the page, or through an Ajax method that automatically updates the list when a new student re ...

Having trouble getting $compile to work in an injected cshtml file with Angular

Summary I am currently working on a large application where everything is designed to be very generic for easy expansion. One of the components I am focusing on is the dialog. Before suggesting alternatives like using ngInclude or angular templates, let m ...

Issue with vertical alignment of text inside select dropdown in Material UI Core

Take a look at the image. The text isn't centered in the text box like the other fields on the form. Dropdown Alignment Issue Below is my code snippet: <FormControl style={{ width: "80%" }} size="small"> <InputLabel htmlFor="Implementation ...

What is the proper way to transfer information to my ajax function from my controller?

I need to dynamically update an element on my webpage based on server-side code events. For example, when I trigger the "Start" function by clicking a button, I want the text inside a specific element to change to "Downloading", and then once the process i ...

In ASP.NET MVC, use CSS styling specifically for Partial Views by encapsulating the styles within a `<style scoped>` tag

A new HTML attribute has emerged, known as scoped, however, it is currently only supported by Firefox. This attribute allows you to declare internal styles solely for the parent element. I am curious if it is feasible to replicate this functionality in AS ...

How can I ensure that the scripts returned in HTML via AJAX are executed when using $.load()?

I have been trying to make an AJAX call and receive a partialView which contains some script that needs to be executed. I did some research and learned about the "eval" method, but then discovered that the $.load() method should handle this for me. Howeve ...

How can I streamline a kendo UI MVC project by eliminating unnecessary components?

After switching my MVC 5 project to utilize Kendo UI, I've noticed a significant increase in the number of files being used. Since there is no need for supporting other cultures at the moment, can I confidently delete the files within the messages an ...

Obtaining HTML elements from JSON using jQuery (i.e., the opposite of serializing with Ajax)

I am looking to extract values from a set of controls (INPUT, SELECT, TEXTAREA) within a DIV and send them as JSON via Ajax to a server. Utilizing jQuery's serializeArray makes this process easy. After sending the JSON data, I expect the server to re ...

Executing a $.get() request in .Net MVC without relying on a controller

In .Net MVC, if I were to utilize the JQuery .get() method for fetching a file from the server, would it still be necessary for me to create a RenderAction within a controller method to display its contents? Here's an example implementation in JQuery: fu ...

Troubleshooting a Pop-up Error and JSON Bug in an MVC Application

Within a JQuery Popup, I am utilizing multiple TextBox controls: <li id="lblAmountPerTurbine"> <label for="AmountPerTurbine"><strong>Amount Per Turbine:</strong></label> <%= Html.TextBox("Amo ...

Why do I keep receiving the unprocessed JSON object instead of the expected partial view output?

Upon submitting my form, instead of displaying the testing alerts I have set up, the page is redirected to a new window where the raw JSON object is shown. My assumption is that this occurrence is related to returning a JSON result from the controller. How ...

Changing a List object into a JSON string in C#

Struggling to convert a List object to a Json string has been a major challenge in my ASP.net MVC project. Model: public class PagerBase<T>:List<T> where T:EntityBase { public int totalpage {get;set;} public int pageindex {get;set;} ...

Error: The JSON data type is not recognized - Asp.Net MVC 4

I've been struggling to send a complex JSON object to my action with no success. Below is my javascript code: $.ajax({ url: "http://localhost:52593/" + urlAction.Controller + "/" + urlAction.Action, type: type, dataType: dataType, data: d ...

The JavaScript library known as Microsoft JScript Angular is not recognized

While integrating Angular into my .Net MVC website, I keep running into a runtime error that reads as follows: 0x800a1391 - Microsoft JScript Runtime Error: 'angular' is undefined. This essentially means that the 'angular' object is not recognized du ...

The Bootstrap modal fails to retrieve and display fresh data from the database

I am facing a challenge in my index view where I display a list of records with an Edit button for users to modify certain details. When the Edit button is clicked, a bootstrap modal pops up allowing users to edit specific fields. After they click Save, th ...

Converting a comma-separated string into individual values for ng-repeat

Here is my HTML code: <div class="jobDiv" data-dir-paginate="item in data.allJobs|filter:categoryFilterFn|orderBy:'item.PublishDate':true| itemsPerPage:10"> <h3> <a href="{{item.JobID}}">{{item.JobTitle}}</a> &l ...

Display the ViewModel in the view once the ajax call has been made

When I make an AJAX call to invoke an action, pass my ViewModel to it, and then attempt to open a new view with a different ViewModel, the redirectToAction and return view methods are not functioning as expected. Other solutions I have come across only inv ...

Looking for a .NET MVC AJAX search solution. How can I enhance the code below?

I am looking to implement a search functionality using AJAX. I have tried using the get method in my controller by passing the search string, but it is not working as expected. Below is a snippet of my controller code, where I retrieve the search value fr ...

Currently struggling to retrieve data from an AJAX post request within a C# controller

I need assistance with sending data from JavaScript to a C# controller using AJAX. However, I am facing an issue where all the arguments in the Add method of my controller are showing up as null. Below is my AJAX code: function sendRequest(name, price, ab ...

Ways to limit access to the jQuery AJAX method from the browser console window

Looking for ways to prevent unauthorized access through the browser console to manipulate the jQuery ajax method. The issue at hand is that anyone can easily access the console and execute a script to repeatedly make requests, causing potential security r ...

The JSON string fails to deserialize and returns a null value

{ "apple": { "A": "xyz", "B": "abc", "C": "jkl" }, "banana": { "A": "lotus", "B": "oil", "C": &qu ...

Using Stored Procedures to Retrieve and Input Information from SQL Server

I have developed a stored procedure that handles inserting and retrieving data from SQL Server. CREATE procedure prc_add ( @name varchar(128)='', @email varchar(128) ='' ) as begin insert into students(name ,email) ...

Sending an array or list of files from AJAX to the Controller

I have a task to upload multiple files and pass them to my Controller's Action. The current code is functional, but I feel there could be room for improvement as it's somewhat manual. I need to display file upload elements based on the number of ...

Filling HTML5 Datepicker Using Information from a Model

Currently, I am in the process of developing a basic scheduling application for a project. To simplify the task of selecting start and end times/dates for our events, we have included a simple DateTime picker in the source code: <input type="datetime-l ...

The issue persists in Angular 5 and asp.net MVC where the ID number continues to increase despite being deleted

Currently, I am using Angular 5 (VS CODE) for the front-end and asp.net mvc/entity framework (VS2017) for the back-end. My CRUD methods are functioning properly; however, I have encountered an issue where the ID of a newly created row keeps increasing even ...

"Implementing ASP.NET MVC4 with Razor: Dynamically filtering a dropdown list based on the selected value from another dropdown

Currently, I am facing a challenge where I need to filter the options of a dropdown list based on the value selected from another dropdown. Within my database, there are tables containing all countries and all cities in the world, with a foreign key linkin ...

Tips for updating the color of a table row when it is chosen and a row is inserted using ajax

I have successfully added table rows dynamically through ajax in MVC C#. Now, I am looking to change the color of a selected row. This effect works well on the table with rows generated in the HTML view. <div class="col-lg-6 col-sm-12"> ...

Sending dynamic boolean model property via AJAX dynamically

I am facing an issue while passing a property from my model to an AJAX form. The boolean value is resolving as "true/false" and causing problems in the process. $.ajax({ url: '/Projects/SearchTable2', type: "GET", data: { sub ...

I am having trouble retrieving a JsonResult from an asp.net mvc controller using $resource in angular

I am new to Angularjs and trying to integrate it with asp.net mvc. I am facing an issue where I am unable to access an asp.net mvc controller to return a JsonResult using $resource in angular. Strangely, when I use $.getJson in JavaScript directly, it work ...

Define a universal URL within JavaScript for use across the program

When working with an ASP.NET MVC application, we often find ourselves calling web service and web API methods from JavaScript files. However, a common issue that arises is the need to update the url in multiple .js files whenever it changes. Is there a me ...

Utilize the Action method selector for distinguishing between Ajax and non-ajax requests, rather than depending on if(Request.isAjaxRequest)?条件

I recently started working through a book titled 'Asp.Net MVC4 in Action'. At one point, the book suggests using an action method selector instead of relying on if statements to check if a request is Ajax. This involves creating a custom class ca ...

Tips for renaming property names during JSON serialization in asp.Net

In my MVC Web API Controller, there is a method that I have exposed: [HttpPost] public JsonResult<CustomClass> Details(RequestClass request) { var encoding = Encoding.GetEncoding("iso-8859-1"); var settings = new ...

The value of $.data is not defined

Below is the HTML code snippet from my MVC razor view: <div style="visibility:visible;"> var info = [ {"id":"1", "bg_color":"Green", "text_color": "Black"}, {"id":"2", "bg_color":"Amber", "text_color": "Black"}, {"id":"3", "b ...

The Web Api has encountered an error with a 302 status code, indicating a failure in authentication. Along with this error, a

I've encountered a perplexing issue and can't seem to find a solution. My web API application works perfectly until it times out. At that point, when I make an AJAX call, the server responds with an empty response as well as an additional one containing a ...

Display user's name in navigation bar using asp.net mvc

When working on an ASP.NET MVC project, I wanted to include a short message for the user, such as 'Hello, username!' In the navigation bar, specifically when the user is signed in, I encountered some display issues with the standard bootstrap la ...

Extract Angular-gettext annotations from a .cshtml file

I am utilizing Angular-gettext to extract strings from .html and .js files for multi-language translation via my Gruntfile.js: grunt.initConfig({ nggettext_extract: { pot: { files: { 'po/template.pot': ['**/*.html', '**/*.csh ...

Issue with change event not firing upon page load

In my production record creation page, I have implemented functionality to handle different line, shift, and date combinations. There are drop down menus for selecting the line and shift, as well as a jQuery date picker for selecting the date. One issue I ...

What is the reason behind ASP MVC model binder's preference for JSON in POST requests?

Is there a way to bind data to a model when sending a 'GET' request with JSON.stringify() using AJAX? Currently, the model value is always null when using 'GET', but it works fine with 'POST'. Are there any solutions for this ...

show the UI changes using AJAX in the controller method

I need help with returning a view in an action called Ajax. The issue I am facing is that when I return JSON, it works fine, but if I try to return a view, it doesn't navigate to the view because the action was called using AJAX. Action: [Route(&q ...

The display within the object array in Angular is failing to show any values

Problem: The angular for loop is not displaying values on line {{ item.Id }}. Although the correct length of 10 is being retrieved, no actual values are shown in the screenshot below. https://i.stack.imgur.com/9keGn.png Debugging: Running console.log(thi ...

Generating HTML within controller actions

I am struggling to make a decision on whether it is acceptable to generate HTML in controller actions and return this HTML to AJAX calls from my view using jQuery. For example, when choosing a client through jQuery Autocomplete, in addition to retrieving ...

Implementing AJAX requests in jQuery DataTable with ASP.NET MVC

For some time now, I have been using the jQuery DataTables 1.10.13 plugin. Recently, I encountered an issue related to the ajax data source for my HTML table. This is how I initialized jQuery DataTable inside Files.cshtml <script language="javascript" ...

Trouble with loading images using AJAX in ASP MVC core 3.0

After successfully fetching data from the API controller using an AJAX request, all the data is loaded correctly, including the image source. However, I have encountered an issue where the controller name is being appended to the image source, resulting in ...

How to send a complex object containing a Dictionary to an MVC controller action using JQuery

Question: I have a model with a Dictionary type field that needs to be posted to the backend controller action. How should I define the model object in JQuery? I keep encountering a primitive error from the ajax call with the code below: var templateBuil ...

Send the user authentication form to a different location by using an AJAX request

I am in the process of developing a .Net Web application using ASP MVC, jQuery & AJAX. Within this application, I have a list of products. When a user clicks on the detail button of a specific product, they are taken to a details view which includes an "Ad ...

Ways to retrieve the chosen option in a dropdown list without specifying the dropdown's name, id,

Custom dropdown, Model-View-Controller Code @foreach (var attribute in Model) { string controlId = string.Format("product_attribute_{0}_{1}_{2}", attribute.ProductId, attribute.ProductAttributeId, attribute.Id); @switch (attribute.AttributeControl ...

How can I remove a row from an MVC webgrid using an ajax call?

Within my MVC Razor view, I have a partial view containing webgrid data. My goal is to include an action link to delete a specific row of data. To accomplish this, I crafted the following JavaScript function: function delMeal(pid) { if (confirm("Do yo ...

Tips for transferring HTML code to a controller

Currently facing an issue while working with MVC and attempting to store HTML code from a view in a database field. In the JS section of my MVC solution, I have the following code snippet: var data = { id_perizia: $("#id_perizia").val(), pinSessione: $("# ...

Issue with MVC framework: AJAX query callback function not functioning properly

Struggling with implementing a basic Jquery Ajax callback: Here is my Jquery code snippet: $(document).ready(function () { $('#btnClient').click(function (e) { e.preventDefault(); var txtClient1 = $('#txtClient').val(); ...

The error message "MVC JS deletethisproduct is not defined at HTMLAnchorElement.onclick (VM457 Index:40)" indicates that there

Upon clicking the button, I encounter this error: "deletethisproduct is not defined at HTMLAnchorElement.onclick" While I understand that using onclick is not the ideal approach, I am employing it because I need to retrieve the product id from the mode ...

Managing Related Data with JSONPlaceholder and MVC 5

Attempting to present a paginated table of information about "Albums" within an MVC 5 project, collecting data from various records sourced through the JSONPlaceholder REST API: View Source Users: (10 entries) { "id": 1, "name" ...

Is there a way to showcase whitespacing in HTML?

I have a database full of content that includes whitespace formatting for display on a webpage. However, when viewed on Stackoverflow using the code tag, the formatting changes. The second way shows how it is stored in the database and how I want it to app ...

Steps to display the leave site prompt during the beforeunload event once a function has finished running

While facing a challenge with executing synchronous Ajax methods in page dismissal events, I discovered that modern browsers no longer support this functionality in the "beforeunload" event. To work around this issue, I implemented a new promise that resol ...

Showcase a picture within a row of a table using Ajax in an MVC framework

Getting straight to the point, I have a similar code snippet in my Controller: return base.File(getSomeImageBitmap, "image/jpeg"); This code successfully displays the image in a new window using @Html.ActionLink. However, I want the image to be directly ...

Incorporating JSON Data into a Collection within my Controller

I have read numerous posts that somewhat touch on my situation, but they all leave me feeling perplexed. Currently, I am sending an object via a POST request to my Controller. I have managed to get the post to reach my controller using the following code: ...

Retrieving cascading values in a dropdownlist using Asp .NET MVC

In my current project, I am using Asp.Net MVC4. In a form, I have implemented cascading dropdown lists. When I select "Distrito" in one dropdown list, it correctly loads the corresponding values for "Sucursal". The insertion of records works fine. However, ...

How can you retrieve newly added DOM elements from a PartialView using Ajax.BeginForm?

Below is a snippet of code that loads a Partial View within a div element: <div id="_customerForm"> @Html.Partial("~/Views/Customer/_customerForm.cshtml", Model.customerForm) </div> The Partial View contains an Ajax Form as shown ...

Navigating between interfaces without the need to constantly refresh or reload

Currently, I am in the process of developing a website using ASP.NET MVC that allows users to navigate between pages without refreshing each time. My approach involves treating views as 'areas' or mini master pages, utilizing partial views inste ...

Eliminate all hover functionalities from the Kendo Menu component in ASP.NET MVC

Currently, I am working on a project and utilizing the Kendo Menu. However, the package includes hover styling that I do not want to use. Is there a way to disable or remove this styling? ...

Making an Ajax request to trigger a method within a controller

Here is the code snippet I wrote: $(function () { $("input#Submit1").on('click', function () { $.ajax({ url: 'Home/GetPort', method: 'GET' }); alert("test") ...

Bootstrap Popover not displaying information after an AJAX request

I'm struggling to update the popovers contents with Ajax result in my ASP.Net MVC4 project. Using ASP.Net (MVC4): public ActionResult GetEmployeeDetails(string employeeId) { var contract = UnitOfWork.ContractRepository.ContractBu ...

Utilizing the Model-View-Controller (MVC) structure in C# to incorporate a WebGrid

Within my WebGrid, I have implemented a link for row deletion inside a PartialView using the following code: @Html.ActionLink("Delete", "DeleteThis", "MyController", new { id = SelectedId }, null) <div id="MyGrid"> @{ var grid = new WebGrid(Mode ...

Retrieve a formatted Word document from a C# endpoint to a Node.js server

I am currently facing an issue with my Node.js server that sends a GET request using axios to a C# endpoint with JSON as a parameter. The C# API then uses Newtonsoft.Json to deserialize the JSON, reads a Word file into memory, and inserts data. The final s ...

When retrieving data from a JSON file, only display the value instead of showing the entire

When a user tries to login, I have created a modal window. If the user enters incorrect credentials, it returns SignInStatus.Failure, which is fine. However, the page then refreshes and only displays the number "3" at the top of the page with no other cont ...

Steps to refresh my View following an Ajax Post request

Working in an MVC environment, I find myself calling a Controller method from my View. The Controller method conducts some validation checks and then returns to the same view with a faulty modelstate. However, despite expecting all of my validation fields ...

Is there a conflict when both Html.BeginForm and an ajax call are used to call the

While attempting to incorporate Ajax to send additional data to my action controller, I encountered an issue where the model parameter became null while the Ajax parameter retained its value. This occurred despite using Html.beginform('index', 'payable') a ...

Leverage Angular variables within HTML tags

Below is the code in my controller.js file: $scope.animatt = 900; and here is the corresponding html code: <div id="properties" data-{{animatt}}="left:100%;top:10%;"> <h2>all numeric properties</h2> </div> I am t ...

How come padding-bottom isn't effective in increasing the position of an element?

My goal is to adjust the position of the orange plus sign (located in the lower right corner of the screen) so that it aligns better with the other icons, directly below them. I've tried using padding-bottom, but it doesn't seem to work, while pa ...