Passing Array to javascript from aspx.cs page
-
Hi All I have one doubt,how to pass array to javascript function from asp.net aspx.cs page.can you help me? Thanks in Advance:rose:
-
Hi All I have one doubt,how to pass array to javascript function from asp.net aspx.cs page.can you help me? Thanks in Advance:rose:
You can send it through embeding server side code -
var jsVariable = '<%= ServerSideVaraible %>';
Anothe approach could be you can use some hidden variable -
<asp:HiddenField ID="HiddenField1" runat="server" />
Once the value is set in the server side you can get the value in javascript -
var sValue = document.getElementById('HiddenField1').value;
If you use AJAX then it would altogether different. Anyway, let me know if you need any further detail. :)
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.
-
You can send it through embeding server side code -
var jsVariable = '<%= ServerSideVaraible %>';
Anothe approach could be you can use some hidden variable -
<asp:HiddenField ID="HiddenField1" runat="server" />
Once the value is set in the server side you can get the value in javascript -
var sValue = document.getElementById('HiddenField1').value;
If you use AJAX then it would altogether different. Anyway, let me know if you need any further detail. :)
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.
Arindam Sinha wrote:
Anothe approach could be you can use some hidden variable -
How will you hold the array in the value of hidden varaible? :doh:
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Hi All I have one doubt,how to pass array to javascript function from asp.net aspx.cs page.can you help me? Thanks in Advance:rose:
You might look at this:
ClientScript.RegisterArrayDeclaration("myarray", "'code project','manas','bhardwaj'");
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Hi All I have one doubt,how to pass array to javascript function from asp.net aspx.cs page.can you help me? Thanks in Advance:rose:
use var x = ["24", "43", "56"]; But I wonder why do you require to pass an array. You can pass the data in a hidden field, and get the data through javascript. You can use comma separated string to show your data. :thumbsup:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Arindam Sinha wrote:
Anothe approach could be you can use some hidden variable -
How will you hold the array in the value of hidden varaible? :doh:
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
Manas...I think any delimeter separator string would suffice... :laugh:
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.