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>