You can't "pass" it per se, as the client side script and the server side script execute at different times. If it is available and in scope at the time your script is generated you can do the usual <%=yourvar%> to pop the current value inline. Otherwise
you need to dynamically generate the script itself and register the client side script block.
Please Mark As Answer posts that helped you.
"If we learn from our mistakes, I should be brilliant by now."
newbeehelp
0 Points
2 Posts
pass value from code to aspx
Feb 21, 2008 08:32 PM|LINK
I have a value in my class which is in my app code.
I need to pass this value to one of my method in javascipt.
How to do that.
vinz
All-Star
127011 Points
17934 Posts
MVP
Re: pass value from code to aspx
Feb 21, 2008 08:46 PM|LINK
From you class assign the Values in aspnet HiddenField control then access it through document.getElementbyId() method in Javascript
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
nikki_doer_o...
Contributor
6863 Points
1097 Posts
Re: pass value from code to aspx
Feb 21, 2008 08:47 PM|LINK
You can't "pass" it per se, as the client side script and the server side script execute at different times. If it is available and in scope at the time your script is generated you can do the usual <%=yourvar%> to pop the current value inline. Otherwise you need to dynamically generate the script itself and register the client side script block.
"If we learn from our mistakes, I should be brilliant by now."
MCTS - .NET Framework 2.0: Web Applications