Dynamically load Web User Controls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack David

    #1

    Dynamically load Web User Controls

    I have a number of web user controls that I want to be able to load into a
    page. I want to be able to define what controls to include in the page, and
    what order they should appear in.
    I am using C#

    Example:
    Web Control 1 = Greeting
    Web Control 2 = Select Credit Card Type

    If Session ScriptID = A then I would want to display
    Greetting
    Select Credit Card Type

    If Session ScriptID = B then I would want to display
    Select Credit Card Type
    Greeting

    If Session ScriptID = C then I would want tp display
    Greeting

    Can I store the location and order in a database table and somehow load this
    into the page when it is rendered??

    Thanks
    Jack David




  • Harald Bjorøy

    #2
    Re: Dynamically load Web User Controls

    I have done similar stuff before by adding a panel; "pnlPlaceholder 1" at the
    desired location, then in code "ctlMyWebContro l=new MyWebControl();
    pnlPlaceholder1 .Controls.Add(c tlMyWebControl) ;"

    This way I get a reference to the control in the main page and I add it
    dynamically. In my situation I had to load several instances of the same
    control, and address them from the main form - this was the solution.

    Regards,
    Harald Bjorøy



    "Jack David" <geckosphere@ho tmail.com> wrote in message
    news:OIGN1ltgDH A.3784@tk2msftn gp13.phx.gbl...[color=blue]
    > I have a number of web user controls that I want to be able to load into a
    > page. I want to be able to define what controls to include in the page,[/color]
    and[color=blue]
    > what order they should appear in.
    > I am using C#
    >
    > Example:
    > Web Control 1 = Greeting
    > Web Control 2 = Select Credit Card Type
    >
    > If Session ScriptID = A then I would want to display
    > Greetting
    > Select Credit Card Type
    >
    > If Session ScriptID = B then I would want to display
    > Select Credit Card Type
    > Greeting
    >
    > If Session ScriptID = C then I would want tp display
    > Greeting
    >
    > Can I store the location and order in a database table and somehow load[/color]
    this[color=blue]
    > into the page when it is rendered??
    >
    > Thanks
    > Jack David
    >
    >
    >
    >[/color]


    Comment

    Working...