admin管理员组文章数量:1336659
I have an ASP.NET Web Forms application in VB.NET
In my application I use a Master Page
and to insert Javascript for a specific page I use a ContentPlaceHolder
.
I have a Javascript where I use code nuggets and I inserted in my page like this:
<asp:Content ID="Content4" ContentPlaceHolderID="javascript" runat="server">
<script language="javascript" type="text/javascript" >
function showErrors() {
var id = '<%=Request.QueryString("id") %>';
<%if (Request.QueryString("errors") == "true") {%>
var errorCode = '<%=Request.QueryString["errorCode"] %>';
var errorMessage = '<%=Request.QueryString["errorMessage"] %>';
<%} %>
}
</script>
</asp:Content>
The problem is that when I build the solution, also the Javascript code gets piled and of course syntax errors are found. For instance one of the build errors is related to the if
statement that does not have a matching End If
(as it is supposed to be in VB.NET)
How can I make the piler understand that it has to skip the Javascript?
I have an ASP.NET Web Forms application in VB.NET
In my application I use a Master Page
and to insert Javascript for a specific page I use a ContentPlaceHolder
.
I have a Javascript where I use code nuggets and I inserted in my page like this:
<asp:Content ID="Content4" ContentPlaceHolderID="javascript" runat="server">
<script language="javascript" type="text/javascript" >
function showErrors() {
var id = '<%=Request.QueryString("id") %>';
<%if (Request.QueryString("errors") == "true") {%>
var errorCode = '<%=Request.QueryString["errorCode"] %>';
var errorMessage = '<%=Request.QueryString["errorMessage"] %>';
<%} %>
}
</script>
</asp:Content>
The problem is that when I build the solution, also the Javascript code gets piled and of course syntax errors are found. For instance one of the build errors is related to the if
statement that does not have a matching End If
(as it is supposed to be in VB.NET)
How can I make the piler understand that it has to skip the Javascript?
Share Improve this question asked Nov 13, 2012 at 10:15 CiccioMiamiCiccioMiami 8,27634 gold badges96 silver badges158 bronze badges 01 Answer
Reset to default 3You have to write the if
statement in VB
language.
<asp:Content ID="Content4" ContentPlaceHolderID="javascript" runat="server">
<script language="javascript" type="text/javascript" >
function showErrors() {
var id = '<%=Request.QueryString("id") %>';
<% If Request.QueryString("errors") = "true" Then %>
var errorCode = '<%=Request.QueryString["errorCode"] %>';
var errorMessage = '<%=Request.QueryString["errorMessage"] %>';
<% End If %>
}
</script>
</asp:Content>
本文标签: Insert Javascript into content page in ASPNET without compiling itStack Overflow
版权声明:本文标题:Insert Javascript into content page in ASP.NET without compiling it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742419124a2471303.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论