Dynamic controls - Adding & Retrieving value

Discussion in 'ASP .Net' started by Ben Amada, Oct 6, 2005.

  1. Ben Amada

    Ben Amada Guest

    I'm a little confused about in what Event should I add dynamic controls and
    in what Event should I retrieve the value of a dynamic control on postback.

    I've found that adding dynamic controls in the Page Load event works, and I
    realize that I need to add the dynamic controls again on each postback. But
    if I'm trying to retrieve the value of a dynamic control (Text property of a
    TextBox for instance), should I retrieve the value in the PreRender event?
    This seems to work, but I don't know if that's when I'm supposed to retrieve
    the value.

    Tia,
    Ben
     
    Ben Amada, Oct 6, 2005
    #1
    1. Advertising

  2. Ben,

    After you re-create the controls, you can access their values in any event,
    even in the same Page_Load. Pick the one that suits your application logic.

    Eliyahu

    "Ben Amada" <> wrote in message
    news:...
    > I'm a little confused about in what Event should I add dynamic controls

    and
    > in what Event should I retrieve the value of a dynamic control on

    postback.
    >
    > I've found that adding dynamic controls in the Page Load event works, and

    I
    > realize that I need to add the dynamic controls again on each postback.

    But
    > if I'm trying to retrieve the value of a dynamic control (Text property of

    a
    > TextBox for instance), should I retrieve the value in the PreRender event?
    > This seems to work, but I don't know if that's when I'm supposed to

    retrieve
    > the value.
    >
    > Tia,
    > Ben
    >
    >
     
    Eliyahu Goldin, Oct 6, 2005
    #2
    1. Advertising

  3. Ben Amada

    Ben Amada Guest

    Eliyahu Goldin wrote:

    > Ben,
    >
    > After you re-create the controls, you can access their values in any
    > event, even in the same Page_Load. Pick the one that suits your
    > application logic.
    >
    > Eliyahu


    Hi Eliyahu,

    I'm not in front of the IDE right now ... however when I was testing this
    earlier, I was recreating the dynamic controls in the Page_Load event during
    a postback, however, after recreating the control, I would check the value
    of the control while still in the Page_Load event, and it was empty (i.e. no
    value).

    If I wait until the PreRender event fires, then the value of the control is
    populated.

    I haven't tested yet whether the value of the control is populated or not
    when a Button's Click event fires, for example (which I believe occurs
    between the Page_Load and PreRender events). Hopefully I'll be able to
    retrieve the value in the Click event as waiting for the PreRender event to
    fire seems like "waiting to the last minute".

    Thanks for your reply!
    Ben
     
    Ben Amada, Oct 6, 2005
    #3
  4. Ben Amada

    chetanwarade

    Joined:
    Aug 23, 2010
    Messages:
    2
    dynamic control

    Here is the solution to add dynamic control and to get its value on Postback
    chetanwarade.wordpress.com/2010/08/21/asp-net-add-dynamic-control-and-retrieve-dynamic-control-value-2/
     
    chetanwarade, Aug 23, 2010
    #4
    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. =?Utf-8?B?QkxpVFpXaU5H?=

    Adding dynamic LinkButton to dynamic table

    =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    765
    =?Utf-8?B?QkxpVFpXaU5H?=
    Jul 27, 2005
  2. Ronald
    Replies:
    2
    Views:
    876
    Robbe Morris [C# MVP]
    Jan 17, 2006
  3. aesquivel
    Replies:
    0
    Views:
    154
    aesquivel
    Jun 10, 2005
  4. Denny Smolinski via .NET 247

    Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

    Denny Smolinski via .NET 247, May 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    510
    Eidolon
    May 4, 2004
  5. asp123 vbnet via .NET 247

    Adding Checkboxlist/checkbox to dataGrid and retrieving selected value

    asp123 vbnet via .NET 247, Mar 25, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    669
    asp123 vbnet via .NET 247
    Mar 25, 2005
Loading...

Share This Page