PDA

Click to See Complete Forum and Search --> : user controls and switch (C#)


Colonel Klink
Sep 3rd, 2003, 11:34 AM
i was wondering, can you use user controls in switch statements... for example


switch (section)
{
case "news":
response.write("<usercontrol1:news></usercontrol1:news>");
break;
case "downloads":
response.write("<usercontrol1:downloads></usercontrol1:downloads>");
break;
}

... etc


im using the querystring to pass along the section page i want to include and change images accordingly (less updating later on down the track)

can you do that? or is there another way?

i hope i made sense

Lethal
Sep 3rd, 2003, 11:39 AM
Use the Page.LoadControl() method. This method allows you to dynamically add a user control to your page. The easiest way I think is to position a placeholder on your page and add it to the placeholder's controls collection.

Colonel Klink
Sep 3rd, 2003, 11:44 AM
ok... i got the first and second sentences, but the last one escapes me

what do you mean by placeholder?

(btw im not using a GUI like VS.NET... im using Dreamweaver MX)

Lethal
Sep 3rd, 2003, 12:48 PM
The Placeholder control is a .NET server control.