Search code examples
javascriptasp.netashx

access javascript variable into the .ashx page


I have a JavaScript, which returns 2 variables. I just want to access those variables in the generic handler(ashx) page but I can't. Can anybody give some suggestion?

var myArray = [txt, value];
var url = "insertComments.ashx?dat=" + myArray.join();

Solution

  • Change your Javascript :

    var url = "insertComments.ashx?datTxt=" + txt + "&" + "datValue=" + value;
    

    and in handler access that values with :

    string txt = context.Request.Params["datTxt"];
    string val = context.Request.Params["datValue"];