Postback of delimited text from javascript and parsing on server side

Posted by Alt_Doru on Stack Overflow See other posts from Stack Overflow or by Alt_Doru
Published on 2010-06-03T13:47:16Z Indexed on 2010/06/03 13:54 UTC
Read the original article Hit count: 149

Filed under:
|
|

In my ASP.NET page, I have a Javascript object, like this:

    var args = new Object();
    args.Data1 = document.getElementById("Data1").value;
    args.Data2 = document.getElementById("Data2").value;
    args.Data3 = document.getElementById("Data3").value;

The object is populated on client side using user input data. I am passing the data to a C# method, through an Ajax request:

    someObj.AjaxRequest(argsData1 + "|" + argsData2 + "|" + argsData3)

Finally, I need to obtain the data in my C# code:

   string data1 = [JS args.Data1]
   string data2 = [JS args.Data2]
   string data3 = [JS args.Data3]

My question is what's the best solution for this? As i am concatenating bits of user input, I don't think it's best to use "|" as a delimiter. Also, it's not clear to me how to actually parse the data in my C# code to populate the three variables with the original data.

© Stack Overflow or respective owner

Related posts about c#

Related posts about JavaScript