Conditional Directive

R

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
 
K

Karl Seguin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top