I\'m trying to use a preprocessor directive in an ASPX page, but the page doesn\'t recognize it. Is this just something I can\'t do?
Background: I\'m trying to inclu
A better approach may be to use server side code to include the script. I'd use something like
protected void Page_Load(object sender, EventArgs e)
{
#if DEBUG
ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "JQueryScript", "resources/jquery-1.3.2.js");
#else
ScriptManager.RegisterClientScriptInclude(this, this.GetType(), "JQueryScript", "resources/jquery-1.3.2.min.js");
#endif
}
I don't think you can have preprocessor directives in the aspx unfortunately.
A simpler way to go is to simply have a property in your code-behind that feeds in the jQuery URL, then you can set preprocessor directives to declare it. Or if you'd prefer to keep the URL in the code-infront you could use a Literal control and toggle their visibility in the code-behind based on the processor directives.
For example:
code-infront:
<asp:literal id="litJQuery" EnableViewState="false" runat="Server">
<script type="text/javascript" src="resources/jquery-1.3.2.js" />
</asp:literal>
<asp:literal id="litJQueryDebug" EnableViewState="false" Visible="false" runat="Server">
<script type="text/javascript" src="resources/jquery-1.3.2.min.js" />
</asp:literal>
code-behind, in the Page_Load method:
#if DEBUG
litJQueryDebug.Visible=true;
litJQuery.Visible=false;
#endif