Conditional Directive

  • Thread starter Thread starter RC
  • Start date Start date
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
 
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
 
Back
Top