Dynamic Controls created by Dynamic Controls

Discussion in 'ASP .Net' started by Ronald, Jan 16, 2006.

  1. Ronald

    Ronald Guest

    Hello,

    For a registration page I need to constantly create controls
    on-the-fly. The input for one control determines the contents of the
    next (mostly DropDownLists) control. This is a pretty common practice I
    would think.

    But, ASP.NET 2.0 will not let me do it. I can dynamically create a
    control and read it's PostBack values in the (next) Page_PreLoad event.
    But, for a subsequent control to be created based on the value of the
    previous control I have to use the next stage, Page_Load. However, for
    a control created so late in the PageCycle, ViewState is not restored.

    I tried many, many different ways to try and solve this, but none
    succeeded. The problem is the PageCycle. It Cycles only once, where I
    would need several Cycles for on PageLoad.

    Any help/workaround would be greatly appreciated.

    Ronald Wijnsema
    Netherlands
     
    Ronald, Jan 16, 2006
    #1
    1. Advertising

  2. Um, I disagree that it's a common practice. Most developers try to scope out
    the business logic of the page, and provide controls whose visibility can be
    turned on or off based on certain criteria rather than getting into a "let's
    create lots of dynamic controls, because we can!" scenario.

    It really sounds to me like you've shot yourself in the foot and need to
    re-think the paradigm.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Ronald" wrote:

    > Hello,
    >
    > For a registration page I need to constantly create controls
    > on-the-fly. The input for one control determines the contents of the
    > next (mostly DropDownLists) control. This is a pretty common practice I
    > would think.
    >
    > But, ASP.NET 2.0 will not let me do it. I can dynamically create a
    > control and read it's PostBack values in the (next) Page_PreLoad event.
    > But, for a subsequent control to be created based on the value of the
    > previous control I have to use the next stage, Page_Load. However, for
    > a control created so late in the PageCycle, ViewState is not restored.
    >
    > I tried many, many different ways to try and solve this, but none
    > succeeded. The problem is the PageCycle. It Cycles only once, where I
    > would need several Cycles for on PageLoad.
    >
    > Any help/workaround would be greatly appreciated.
    >
    > Ronald Wijnsema
    > Netherlands
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jan 16, 2006
    #2
    1. Advertising

  3. I'm not 100% certain what your exact requirements are.
    However, this article demonstrates how to recreate
    "dynamically created" controls based on the Request.Form
    collection.

    You may find it useful.

    http://www.eggheadcafe.com/articles/extendtextboxviewstate.asp

    --
    Robbe Morris - 2004-2006 Microsoft MVP C#
    http://www.eggheadcafe.com/forums/merit.asp





    "Ronald" <> wrote in message
    news:...
    > Hello,
    >
    > For a registration page I need to constantly create controls
    > on-the-fly. The input for one control determines the contents of the
    > next (mostly DropDownLists) control. This is a pretty common practice I
    > would think.
    >
    > But, ASP.NET 2.0 will not let me do it. I can dynamically create a
    > control and read it's PostBack values in the (next) Page_PreLoad event.
    > But, for a subsequent control to be created based on the value of the
    > previous control I have to use the next stage, Page_Load. However, for
    > a control created so late in the PageCycle, ViewState is not restored.
    >
    > I tried many, many different ways to try and solve this, but none
    > succeeded. The problem is the PageCycle. It Cycles only once, where I
    > would need several Cycles for on PageLoad.
    >
    > Any help/workaround would be greatly appreciated.
    >
    > Ronald Wijnsema
    > Netherlands
    >
     
    Robbe Morris [C# MVP], Jan 17, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulf Heyder
    Replies:
    0
    Views:
    570
    Ulf Heyder
    Oct 16, 2003
  2. jimjim
    Replies:
    12
    Views:
    1,898
    Ron Natalie
    Jun 3, 2005
  3. tom c
    Replies:
    6
    Views:
    508
    tom c
    Sep 6, 2006
  4. Sunfire
    Replies:
    1
    Views:
    485
    Roland Dick
    Nov 10, 2007
  5. msimmons
    Replies:
    0
    Views:
    497
    msimmons
    Jul 16, 2009
Loading...

Share This Page