I want to be able to point to one of 2 assemblies based on what mode (DEBUG or RELEASE) I have selected in my VS2005 IDE. Something like this (which does not work):
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VideoDialog.ascx.cs" Inherits="Company.Web.Base.Controls.VideoDialog" %>
<% #if DEBUG %>
<%@ Register TagPrefix="Company" Assembly="Company" Namespace="Company.UI.Controls.VideoControl" %>
<% #else %>
<%@ Register TagPrefix="Company" Assembly="Company.UI.Controls.VideoControl" Namespace="Company.UI.Controls.VideoControl" %>
<% #endif %>
<Company:CompanyVideo ID="Video1" runat="server"></Company:CompanyVideo>
So, my question is: How do I correctly use a #if DEBUG in an ASPX or ASCX page?
I don't know how to get what you want, but I face the same problem. I do my control references in web.config and then do post build steps to copy the appropriate web.config for release/debug. It works because you need a different web.config for release/debug anyhow (if only for the debug="true" attribute) and because you can have a different post build step for debug and release.
<%
//<compilation debug="false"> in web.config
//*.aspx
#if DEBUG
Response.Write("<script type=\"text/javascript\">");
Response.Write("$.validator.setDefaults({ debug: true })");
Response.Write("</script>");
#endif
%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With