# if DEBUG for asp and html

Need Debug and release for aspx or html.

</head>
    
    <body class =" bodyMain"
    <% #if !DEBUG %>   
        onload="detectIframe();"      
    <% #endif %>
        >
    <form id="form1" runat="server"> ........

AND

<div id="divDebug" 
            <% #if !DEBUG %>   
                hidden ="hidden"
            <% #endif %>
                >    
                   
                <table class="contentTable">.......

Open in new window


I have not been able to get this to work.  I have got this to compile as html but asp: I have not been able to even get it to compile.  I am open to any other way to get some conditional compilation.

Kind Regards
Sam
SamCashAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Ioannis ParaskevopoulosCommented:
Hi,

Not really my field, but can you try:

    
    <% #if !DEBUG %>   
        <body class =" bodyMain" onload="detectIframe();">
    <% #else %>
        <body class =" bodyMain">
    <% #endif %>
        

Open in new window


and:


    
    <% #if !DEBUG %>   
       <div id="divDebug" hidden ="hidden">
    <% #else %>
        <div id="divDebug" >
    <% #endif %>
        

Open in new window


Giannis
0
 
käµfm³d 👽Commented:
Is this classic ASP or ASP.NET?
0
 
SamCashAuthor Commented:
Giannis,

That was my first attempt (simple C convention).  Html ,asp, aspx, asp.net all new to me also.  Your suggestion  does not compile(build) on vs2012.  The first 'body' reports missing closing tag and the second 'body' reports cannot be nested within element 'body'.

Thanks for your response.  Hopefully this thread will ultimately help future developers.

kaufm3d,

ASP.NET.  Also available on the pages is ajax. We are using the "c# code behind" scheme.  

The actual issue is; On page_load we are setting local variables from the url, database, and authenticated user, which variables are used throughout the page(s), when developing locally the url is not valid, we use a different database and do not want to log in every time, or may want to log in as a different user, and may want to work on one page and not all the others in the parent frame.  We have the code working for development and release.  But we have to alternate commenting and un-commenting the appropriate sections on the aspx page.  This code is at the top of each aspx page.  The compiler directive works great on the code behind pages.  But have not succeeded on the aspx pages, yet.

Regards
Sam
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
SamCashAuthor Commented:
Update, solved the div issue, a little embarrassed...

.aspx
<div id="divDebug" runat="server">

Open in new window


.aspx.cs
#if !DEBUG //RELEASE
                divDebug.Visible = false; //hide debug division

Open in new window


I have not figured out how to use this technique on the detectIFrame part, still working and searching...

Regards
Sam
0
 
SamCashAuthor Commented:
This works for my application.

.aspx
<body runat="server" id="bodyMain" class="bodyMain">

.aspx.cs
#if !DEBUG //RELEASE
                bodyMain.Attributes.Add("onLoad", "detectIframe();"); //Force to load inside Iframe by redirecting to "/default.aspx"

.js
function detectIframe() {
    var framesetpage = "/default.aspx"
    if (parent.location.href == window.location.href)
        parent.location.href = framesetpage
}

Open in new window


Regards
Sam
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
SamCashAuthor Commented:
I hope someone more experienced than I reviews this and applies "Best Practices" to my hack.

I believe all  # if DEBUG and !DEBUG function can be more effectively  made from the code behind.

Sam
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.