Wednesday, July 25, 2012

asp.net – How can I send an array of string from C# to client side?



How can I send an array of string from ASP.NET(C#) to javascript using the jQuery ajax technique ??


I know how to do it for a normal string, but i need to implement it with an array of string.


can I use the \’Response.Write\’ with an array ?? if yes, then how can I read it from the client side ?? how can i read array from there ??


this is from server side :



protected void Page_Load(object sender, EventArgs e)
{

string[] arr1 = new string[] { \"one\", \"two\", \"three\" };


Response.Write(arr1);
Response.End();

}


This is from the client side:



$(document).ready(function(){


$(\':button\').click(function(){

var text_result = \"ok\"

$.post(\'default.aspx\', { text_res: text_result} , function(data){

alert(\"The result is: \"+data);

}).error(function(){

alert(\"Error is occured\");

});

});


});


this is not working(for array), but its working for normal data

Thanks alot






Rating: 3 out of 5 based on 4 ratings



The post asp.net – How can I send an array of string from C# to client side? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/asp-net-how-can-i-send-an-array-of-string-from-c-to-client-side.html

No comments:

Post a Comment