There are two possible ways to answer this question.
1) The short answer is you can't do exactly what you're attempting.
The first thing to understand is that the code between the server tags <% %> is only server side code.
The tag...
<%=
...means the server will generate the output and send the result to the client.
Javascript & jQuery code is client-side code only.
So your javascript / jQuery can not interact directly with the server side code. However, you can generate the client-side code from the server-side.
2) How do we get a value from the client-side code to the server-side?
There are a couple of approaches to this, and it will depend on the style you've chosen for your web application, and the problem at hand.
- Post or Get to a URL - this could be
using performed using AJAX.
- Generate the javascript / jQuery code
you need on the server so you don't
need to "post back".