sending value of model property as an ajax parameter

sending value of model property as an ajax parameter

By : David
Date : November 20 2020, 09:01 AM
hop of those help? @Url.Action() is razor code which is evaluated on the server before its sent to the view so if the initial value of Model.Product_ID is null then your code will render just url: '/Home/CreateDirectory'. Changing the value in the textbox once it has been generated will not update the value of url.
Instead use the ajax data option to pass the value of the textbox
code :
$('#idd').click(function () {
        url: '@Url.Action("CreateDirectory", "Home")', // modify
        data: { product_ID: $('#Product_ID').val() }, // add this
        type: "POST",

Share : facebook icon twitter icon
Ajax call Parameter does not accept @Model as parameter value

Ajax call Parameter does not accept @Model as parameter value

By : lakiluki
Date : March 29 2020, 07:55 AM
around this issue I have following code which is making an Ajax call from a .CSHTML file. , To use Razor in JS, wrap the attributes in '',
code :
data : '@Model.EmployeeId',  

//For passing integer use parseInt('@Model.EmployeeId') or Number('@Model.EmployeeId')
var model = {
        EmployeeId: '@Model.EmployeeId',
data : @Model.EmployeeId + "",
Sending GET from PHP parameter to AJAX

Sending GET from PHP parameter to AJAX

By : Mehdi Kazi
Date : March 29 2020, 07:55 AM
this one helps. My coding isn't working. Please anyone could tell me why? Here's the code: , You need to have quotes around string parameters in js:
code :
sale(<?= $ritem['stock_code'] ?>, 1)
sale('<?= $ritem['stock_code'] ?>', 1)
How do I Bind my Ajax Call Parameter to My Controllers Model Parameter

How do I Bind my Ajax Call Parameter to My Controllers Model Parameter

By : user2360828
Date : March 29 2020, 07:55 AM
around this issue Sorry to waste everyone's time but here was the issue:
This line in the controller has a parameter of t:
code :
public JsonResult testing(test t)
       data: {
          test: testObj
Model vs List<Model> when sending post request to controller using Ajax

Model vs List<Model> when sending post request to controller using Ajax

By : DomRow
Date : March 29 2020, 07:55 AM
help you fix your problem I usually use this method to send my Model as a List to my Controller method. I will try to show you regarding your scenario, how you can do this:
code :
 $("body").on("click", "#btnSave", function () {

    var list= new Array();
    list = [{ myfieldName: 'ABC'}, { myfieldName: 'DEF'}];

    //Send the JSON array to Controller using AJAX.
            type: "POST",
            url: "@Url.Action("Create","Project")",
            data:{"json": JSON.stringify(list)},
            dataType: "json",
            success: function (r) {
                alert(r + " record(s) inserted.");
using System.Web.Script.Serialization

public JsonResult Create(string json)
    var serializer = new JavaScriptSerializer();
    dynamic jsondata = serializer.Deserialize(json, typeof(object));
    List<string> myfieldName=new List<string>();
    //Access your array now
    foreach (var item in jsondata)

    //Do something with the list here
    return Json("Success");
Sending ASP.NET Model through AJAX

Sending ASP.NET Model through AJAX

By : Rajesh Uppala
Date : March 29 2020, 07:55 AM
I wish this helpful for you Your syntax would work fine for a primitive variable, but you should serialize your object to Json before sending. And also make sure that script stays in cshtml or aspx page, else '@Html' helper will not work.
Related Posts Related Posts :
  • Why do I get a COMException when I try to initialize an Interop.Word.Application?
  • Finding subtotal for column in repeater control
  • dropdownlist item selected throw exception (stack empty)
  • How can I list IIS working processes programmatically?
  • How to access nested object from JSON with Json.NET in C#
  • OpenXml DataValidation set predefined List for columns
  • How to find recurring word groups in text with C#?
  • layout conrols to developp universal apps in windows 8.1 pro
  • Adding strings to a list via for loop xna
  • Using Vertex Arrays with OpenTK
  • Optimizing List<string>
  • C# Local variables
  • How can I merge the results of a group by Linq-to-XML query?
  • How to add Report in ASP.NET Project
  • C# How to display all instances of a loop in a label?
  • C# subscribe a function to System.Action that is subscribed to another System.Action: why does order matter?
  • Is there any negative effect to setting SqlCommand's CommandTimeout to a high value?
  • C# - TreeView Context Menu Out of Place when using keyboard
  • How to read stored procedure output and return it as list
  • How do you maintain changes made by VisualState triggers after setting another VisualState?
  • Should I be unit testing my bootstrapper and if so how?
  • using .SingleOrDefault() inside .Where() will raise the following exception:- System.NotSupportedException was unhandled
  • C# How would I fill a Form1 Parameter in the same seperate class
  • Access gridview row's data from LinkButton inside that row
  • Translating excel function to c# Math.pow not resulting in same values
  • Arranging Ten Inputted Numbers into Ascending and Descending order
  • AsEnumerable and Query Syntax
  • How can I defensively code against randomly referencing "Table 0" and null values?
  • Changing xaml code position based on screen size
  • Castle Windsor resolve ienumerable and name
  • Drawing multiple sprites with a for loop xna 4.0
  • For loop to Populate Textblocks
  • Visual Studio 2015: Create an Empty Project
  • What are .NET classes to replace the old MSXML2.ServerXMLHTTP?
  • Handle leak in .Net threads
  • Excel add-in ribbon click events bubbling
  • validation rule needed for only numbers to be entered
  • Parsing complex XML, no descendent elements exists when selecting a named element
  • Web Api - IEnumerable with complex type as param is null
  • Email address input validation
  • .Net AND operator Regular Expression using strings in a document
  • Windows phone 8.1 POST x-www-form-urlencoded not working
  • Is there any way to make my C# XMLManager work?
  • ASP.NET 5 Console Application (package) - How to create DBContext from connection string?
  • How to use form's function in other class C#
  • WPF Zebra EPL2 Printing issue
  • C# use reflection to capture exception throw
  • Convert strings in DataRow to double
  • Xml-Serialization is not working
  • HTML Agility Pack can't find classes with trailing spaces
  • ComputeHash Calls Inexplicably Differ
  • Creating an array that holds both integers and datetime C#
  • GroupBy multiple columns in Linq with Take()
  • Rename multiple symbols at once? (using Roslyn)
  • Cast lambda in delegate
  • DataContractSerializer using default properties
  • LINQ Query Sum in recordset
  • change left-hand boolean value to be opposite of the right hand value
  • Get node from XmlDocument using xpath
  • Why does a Control's BeginInvoke() target delegate never occur after Dispose() is called on the Control?
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co