Passing a C# variable to included javascript file
-
I few sites said to (in the js file) put the varible in <%= %> these tags but thats not doing any good. Is there some other part needed to this I'm missing. The javascript I'm using is in a file I included in my VS project.
It will only work if it's in the markup for your page not in a seperate javascript file.
I know the language. I've read a book. - _Madmatt
-
It will only work if it's in the markup for your page not in a seperate javascript file.
I know the language. I've read a book. - _Madmatt
-
is there any way at all to get a value from one to the other? Well.. I don't need it to go two ways..
JavaScript file
function SomeFunction()
{
alert(myVar);
}ASPX file
var myVar = <%= SomeValue %>
</pre>Code behind
<pre>public string SomeValue{ get; set;}</pre>
<div class="signature"><hr />I know the language. I've read a book. - _Madmatt</div></x-turndown> -
JavaScript file
function SomeFunction()
{
alert(myVar);
}ASPX file
var myVar = <%= SomeValue %>
</pre>Code behind
<pre>public string SomeValue{ get; set;}</pre>
<div class="signature"><hr />I know the language. I've read a book. - _Madmatt</div></x-turndown> -
Forgot to mention I'm working with a WPF app and the html is included with that. How would all this work and be placed in that?
Forgot? This is a critical piece of information that could have saved us botth a lot of time. You can't use the <% %> syntax in this situation. There is no ASP.NET engine involved that will parse and render these tags.
I know the language. I've read a book. - _Madmatt
-
Forgot? This is a critical piece of information that could have saved us botth a lot of time. You can't use the <% %> syntax in this situation. There is no ASP.NET engine involved that will parse and render these tags.
I know the language. I've read a book. - _Madmatt