List<string> is a .net construct that resides in the memory of your server. Client-side js can't access this variable for many reasons. Not least of which is that the variable is destroyed before the html is sent to the browser so ControlIds no longer
exists. Second of all, in order for your js to update the data it would require that the browser understands .net compiled code and the framework and is able to serialise memory updates over the internet, so your code wouldn't work on machines without .net
installed.
If you explain a bit more what it is you're trying to do we might be able to give practical help. The solution to your problem is probably creating a javascript array from your data so that you *can* add to it on the client. An example of doing this is
here
Member
20 Points
196 Posts
Adding to List of Strings
Sep 03, 2014 06:29 AM|mrhammad|LINK
I have declared List of strings as
and i want to assign/add value using following function. it does call function but does not add any value
JQuery mvc asp.net
All-Star
37441 Points
9078 Posts
Re: Adding to List of Strings
Sep 03, 2014 06:39 AM|AidyF|LINK
List<string> is a .net construct that resides in the memory of your server. Client-side js can't access this variable for many reasons. Not least of which is that the variable is destroyed before the html is sent to the browser so ControlIds no longer exists. Second of all, in order for your js to update the data it would require that the browser understands .net compiled code and the framework and is able to serialise memory updates over the internet, so your code wouldn't work on machines without .net installed.
If you explain a bit more what it is you're trying to do we might be able to give practical help. The solution to your problem is probably creating a javascript array from your data so that you *can* add to it on the client. An example of doing this is here
http://forums.asp.net/t/2005947.aspx?Updating+a+razor+variable
JQuery mvc asp.net