I am trying to get a string from a textbox in a .aspx page. When I debug my site jQuery.post is able to see the input value, but when I try to get the value in my handler, he is giving me NULL back. Anyone help!!!
JS:
CompanyName = $("#company").val();
jQuery.post('/CartHandler.ashx', { 'CompanyName': CompanyName });
ASHX:
public void ProcessRequest(HttpContext context)
{
string ImeTvrtke = context.Request.QueryString["CompanyName"];
}
When you make a POST request, the value is not sent as part of the query string. So don't look in the query string for it. Retrieve it like this:
string ImeTvrtke = context.Request["CompanyName"];
Alternatively if you wanted to be sent as part of the query string then use a GET request:
jQuery.get('/CartHandler.ashx', { 'CompanyName': CompanyName });