I can't find a way to pass values from a javascript file, (that I got from a html file from an onclick event), to a aspx.cs file.
I tried using the following code. Every article seems to show this way but the error keeps getting called, also tried with 'type' instead of 'method'.
.js file:
//get 'name' variable here
$.ajax({
url: 'WebForm.aspx/Send',
dataType: "json",
method: 'post',
contentType: "application/json; charset=utf-8",
data: { name: name },
success: msgsuccess,
error: msgerror
});
WebForm.aspx.cs file:
[WebMethod]
public static string Send(string name)
{//breakpoint here
//code
}
The code never gets to the breakpoint in the aspx.cs file, therefore the code value never gets passed.
This is my first post in stack overflow, sorry if anything is wrong formatted.