Results 1 to 4 of 4

Thread: user controls and switch (C#)

  1. #1

    Thread Starter
    Hyperactive Member Colonel Klink's Avatar
    Join Date
    Aug 2002
    Location
    Gold Coast, Australia
    Posts
    329

    user controls and switch (C#)

    i was wondering, can you use user controls in switch statements... for example

    Code:
    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

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

  3. #3

    Thread Starter
    Hyperactive Member Colonel Klink's Avatar
    Join Date
    Aug 2002
    Location
    Gold Coast, Australia
    Posts
    329
    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)
    Our Father, who 0wnz heaven, j00 r0ck!
    May all 0ur base someday be belong to you!
    May j00 0wn earth just like j00 0wn heaven.
    Give us this day our warez, mp3z, and pr0n through a phat pipe.
    And cut us some slack when we act like n00b lamerz, just as we teach n00bz when they act lame on us.
    Please don't give us root access on some poor d00d'z box when we're too pissed off to think about what's right and wrong, and if you could keep the fbi off our backs, we'd appreciate it.
    For j00 0wn r00t on all our b0x3s 4ever and ever, 4m3n.

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    The Placeholder control is a .NET server control.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width