Simple question - C# includes

  • Thread starter Thread starter porter
  • Start date Start date
P

porter

Im guessing this is a really simple question. How do server-side
includes work in c#? For example, I have a swtich statement and
depending on its output, I want to include different files. I had the
code in VB and then tried to port it over but I just cant find the C#
file comand.

switch(kind)
{
case "parts":
page += "manuals_parts.aspx";
break;
case "service":
page += "manuals_service.aspx";
break;
case "operator":
page += "manuals_operator.aspx";
break;
case "specs":
page += "manuals_specs.aspx";
break;
case "schematics":
page += "manuals_schematics.aspx";
break;
default :
page += "manuals_main.aspx";
break;
}

*** VB would then say Response.Writefile(page)

what is it in c#?
 
You should create a Web User Control then dynamically load them depending on
the switch.



I would use a PlaceHolder control then do something like this:

Control myControl;

switch(kind)

{

case "parts":

myControl = LoadControl("MyPartsControl.ascx");

break;

case "service":

myControl = LoadControl("MyServiceControl.ascx");

break;

}



myPlaceHolderControl.Controls.Add(myControl);



Regards,

Brian K. Williams
 
Back
Top