Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:56:26+00:00 2026-05-13T22:56:26+00:00

I need the the .ASPX file to behave differently based on a conditional compilation

  • 0

I need the the .ASPX file to behave differently based on a conditional compilation symbol.

Let’s say as an easy example:

<%@ Control Language="C#" AutoEventWireup="true" (...) %>
<% #ifdef DEBUG %>
     <asp:SomeDebugControlHere runat="server"/>
     .. well .. a LOT of code here
<% #else %>
    <asp:SomeReleaseControlHere runat="server"/>
    .. and a LOT of other code here
<% #endif %>

Later Edit: a few more clarifications. The problem is that the class SomeDebugControlHere is not even defined in the release build (it’s way more complicated in real-life, but bear with this example). So in the page.aspx.designer.cs I need to get this in the debug build:

/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.SomeDebugControlHere myControl

and this in the release build: (and never both)

/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.SomeReleaseControlHere myControl

Obviously I need the mark-up in the ASPX file to be different, but I need the designer.cs file to be modified as well to incorporate the new objects/classes.

I’m just hoping somebody knows of a clever way of doing this either by some control inheritance, anything that would allow me to specify different control classes depending on compilation build settings.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:56:26+00:00Added an answer on May 13, 2026 at 10:56 pm

    It seems there is a difference when compiling with the compilation symbols depending on where you declare them: As a project property, using a @Page directive or in web.config.

    Only the symbols defined in web.config seem to be working in the .aspx files.

    <compiler
          language="c#;cs;csharp" extension=".cs"
          compilerOptions="/d:MY_CONSTANT"
          type="Microsoft.CSharp.CSharpCodeProvider, 
            System, Version=2.0.0.0, Culture=neutral, 
            PublicKeyToken=b77a5c561934e089" />
        </compilers>
    

    Found some info on this here and here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 327k
  • Answers 327k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The variable $$ contains the PID. May 14, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer This is not valid C++ code. TEST is not dependent… May 14, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer I ended up using PHPExcel. With this class I can… May 14, 2026 at 1:50 am

Related Questions

I have quite simple site structure with one mastepage and a bunch of pages.
I have made some progress with the DataList and UserControl this morning but I
I have a report page that can display two different reports. So I have
I need to instantiate some ASP LinkButtons onto an ASP.NET MVC view page. I've
I've got a form inside an <asp:Content> block that is being submitted to a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.