Postback of delimited text from javascript and parsing on server side
- by Alt_Doru
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.