On开发者_Python百科 my aspx view, I would like to generate javascript where some parts are generated:
before generation:
<script type="text/javascript">
var A = 'an id';
var B = "http://www.yahoo.com" + <%= Model.pathname %>;
</script>
After generation:
<script type="text/javascript">
var A = 'an id';
var B = "http://www.yahoo.com/videos/index.htm" ;
</script>
is this possible? what options do I have?
I suggest the following code:
<script type="text/javascript">
var A = 'an id';
var B = "http://www.yahoo.com<%= Model.pathname %>";
</script>
Maybe the IntelliSense is not completely right in Visual Studio, but it will work.
yes, it's entirely possible, javascript is not executed untill way after all of this stuff is rendered, you have pretty much whatever options you can imagine.
Yes this should work fine, just surround the directive with single quotes for example:
<script type="text/javascript">
var A = 'an id';
var B = "http://www.yahoo.com" + '<%= Model.pathname %>';
</script>
Yes, that's possible.
If the JavaScript code is in your view, then simply doing the: <%= Model.pathname %>
would work.
精彩评论