I have a public property in my code behind named Tab which I'm trying to access in the pages aspx file with javascript but I'm not sure how to get the right value.
This gives me the value I want
alert('<% Response.Write(this.Tab); %>');
This does not
var x = <% =this.Tab %>;
alert(x);
Any ideas?
If you view the source you are probably seeing
var x = mystring;
I would guess you want the quotes too
var x = "<%= this.Tab %>";
Instead of having code inline, why don't you look at RegisterStartUpScript or RegisterClientScriptBlock.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With