I have an ASPX.CS code:
Protected int myprop
I would like to call it on a JS assignment :
<script type='text/javascript'>
...
data.add(['SomeJSProperty', "<%..myprop from code behind%>"]);
I remember doing it with <% %> inline code and it used to view the code behind protected and public members. but it won't work now.
Thanks
Try this:
<script type='text/javascript'>
...
data.add(['SomeJSProperty', "<%= myprop %>"]);
More info on MSDN .
In the page_load you can add a input type='hidden' value='my prop' to the page. and from javascript when document is ready you can simply read that value from the hidden input.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.