473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Conditional Directive

RC
Is it possible to do following task? Any concret sample code to do that?
Following code is not work.

<% if ((bool)Application["debug"]){
Control codebehind="abc.cs" inherts="ABC.ClassA"
else {
Control src="abc.ascx.cs" inherts="ABC.ClassA"
}%>

thanks
Nov 19 '05 #1
1 1110
No.

You can dynamically load user controls via Page.LoadControl which would
allow you to load one user control or another based on some condition. But
you seem to want to change the @Control directive programmatically in order
to specify a codebehind instead of a src. First of all, the two aren't
interchangable, codebehind and src are nothing to each other. Ignore
CodeBehind, all that does it tell VS.Net which file to open. Rather, the
runtime uses either inherits or src in order to determine which file to
compile in order to serve as the base class. Even with that little lesson,
as far asI know you can't change it. I'm not sure WHY you'd want to....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"RC" <rc@gmail.com> wrote in message
news:%2*****************@TK2MSFTNGP14.phx.gbl...
Is it possible to do following task? Any concret sample code to do that?
Following code is not work.

<% if ((bool)Application["debug"]){
Control codebehind="abc.cs" inherts="ABC.ClassA"
else {
Control src="abc.ascx.cs" inherts="ABC.ClassA"
}%>

thanks

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris P | last post by:
I have set a conditional compilation preprocessor directive in the Project>Properties Build page. The variable is retained in the project when exiting VS and returning. However, the code that is...
4
by: Zarko Gajic | last post by:
Hi, Is there a way to include an #If ... directive in my code to enable conditional compilation based on the framework version? The idea is to be able to compile the "same" code for both the...
12
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
2
by: FireStarter | last post by:
Guys, in the code that follows, why does the method F() still compile, even if DBG is undefined? Inside method G(), the code inside <#if DBG> does not compile (notice that I can write whatever I...
7
by: John Dolinka | last post by:
I have a project of several files with #defines to setup a conditional compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the...
3
by: ARZ | last post by:
Hi How do I include DLLs based on a condition. Eg., there are 2 DLLs 'Oracle.dll' and 'SQL.dll'. I need to include ANYONE of the DLLs based on a value. Is it possile in C# Thanks in advance ARZ
2
by: Simon | last post by:
Hi, Is possible to use a conditional directive to build a special version of asp.net 2.0 web application ? Thanks Simon.
10
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
3
by: ezmeralda | last post by:
Hello, I have some code which shall be compiled in .NET v1.1 and v2.0 but which has to be different for the two .NET-Versions. Therefore I need to use a construct like #if NET_20 <2.0...
1
by: Sagaert Johan | last post by:
Hi Is there a constant i could use to force conditional compilation based on whether i compile for CF or the Full NET framework ? Johan
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.