Retrieving User's Input from Dynamically added WebControls

Discussion in 'ASP .Net' started by Dotnet Gruven, Jan 20, 2006.

  1. I've built a WebForm with a Table added dynamically in Page_Load when
    IsPostBack is false. The table includes a couple of TextBoxes,
    RadioButtonLists and CheckboxLists.



    On postback, those controls are not present nor their valves in
    Request.Form.AllKeys.



    What is the strategy to use in order to accomplish list? (Pointers to tech
    articles would be very helpful, as I'm not even sure where to start)



    TIA,

    geo
    Dotnet Gruven, Jan 20, 2006
    #1
    1. Advertising

  2. I think you should make these controls as Server side controls ( runat =
    server), define them in the code behind file, and then use them.

    Here is a weak pointer http://www.asp101.com/lessons/htmlcontrols.asp

    HTH,
    r.



    > I've built a WebForm with a Table added dynamically in Page_Load when
    > IsPostBack is false. The table includes a couple of TextBoxes,
    > RadioButtonLists and CheckboxLists.
    >
    > On postback, those controls are not present nor their valves in
    > Request.Form.AllKeys.
    >
    > What is the strategy to use in order to accomplish list? (Pointers to
    > tech articles would be very helpful, as I'm not even sure where to
    > start)
    >
    > TIA,
    >
    > geo
    >
    Ranjan Sakalley, Jan 20, 2006
    #2
    1. Advertising

  3. Thanks for your input Ranjan, perhaps I wasn't very clear.

    They are server controls, since they are created in code. It would be much
    easier if I could define them declaratively, however, I don't know before
    the request is made, based upon the Query string and what that points to in
    the database, what the page should contain.

    Having looked into this further, it looks like the page life cycle might
    hold the answer. Perhaps I should create the controls in another page event
    other than Page_Load??

    Basically, I need to know how to create controls dynamically so that I can
    get the values out on the postback.

    TIA,
    geo


    "Ranjan Sakalley" <construqt.yahoo.com> wrote in message
    news:...
    >I think you should make these controls as Server side controls ( runat =
    >server), define them in the code behind file, and then use them.
    >
    > Here is a weak pointer http://www.asp101.com/lessons/htmlcontrols.asp
    >
    > HTH,
    > r.
    >
    >
    >
    >> I've built a WebForm with a Table added dynamically in Page_Load when
    >> IsPostBack is false. The table includes a couple of TextBoxes,
    >> RadioButtonLists and CheckboxLists.
    >>
    >> On postback, those controls are not present nor their valves in
    >> Request.Form.AllKeys.
    >>
    >> What is the strategy to use in order to accomplish list? (Pointers to
    >> tech articles would be very helpful, as I'm not even sure where to
    >> start)
    >>
    >> TIA,
    >>
    >> geo
    >>

    >
    >
    Dotnet Gruven, Jan 20, 2006
    #3
  4. Hi Geo,

    As for dynamic ASP.NET server controls, both Page_Init and Page_Load is the
    possible place to create and add them. However, Init is the prefered one
    since the Page haven't begun loading viewstate at that time.... So the
    general steps for creating dynamic webcontrols and retrieve values from
    them in other events are:

    1. creating them in Page Init or Load events and add them into page's
    control collection/hierarchy...

    2. In page's post back events (not init or load events) , read their
    properties, since at that time, we can ensure the dynamic controls are
    created and have restored their properties from viewstate and the posted
    values....

    Here is a kb article mentioned create dynamic server controls in asp.net
    webform:

    #HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
    http://support.microsoft.com/kb/317794/en-us

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)





    --------------------
    | From: "Dotnet Gruven" <>
    | References: <>
    <>
    | Subject: Re: Retrieving User's Input from Dynamically added WebControls
    | Date: Fri, 20 Jan 2006 11:58:11 -0500
    | Lines: 49
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    | X-RFC2646: Format=Flowed; Response
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    | Message-ID: <#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: c-24-128-25-74.hsd1.ma.comcast.net 24.128.25.74
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet:372449
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Thanks for your input Ranjan, perhaps I wasn't very clear.
    |
    | They are server controls, since they are created in code. It would be
    much
    | easier if I could define them declaratively, however, I don't know before
    | the request is made, based upon the Query string and what that points to
    in
    | the database, what the page should contain.
    |
    | Having looked into this further, it looks like the page life cycle might
    | hold the answer. Perhaps I should create the controls in another page
    event
    | other than Page_Load??
    |
    | Basically, I need to know how to create controls dynamically so that I
    can
    | get the values out on the postback.
    |
    | TIA,
    | geo
    |
    |
    | "Ranjan Sakalley" <construqt.yahoo.com> wrote in message
    | news:...
    | >I think you should make these controls as Server side controls ( runat =
    | >server), define them in the code behind file, and then use them.
    | >
    | > Here is a weak pointer http://www.asp101.com/lessons/htmlcontrols.asp
    | >
    | > HTH,
    | > r.
    | >
    | >
    | >
    | >> I've built a WebForm with a Table added dynamically in Page_Load when
    | >> IsPostBack is false. The table includes a couple of TextBoxes,
    | >> RadioButtonLists and CheckboxLists.
    | >>
    | >> On postback, those controls are not present nor their valves in
    | >> Request.Form.AllKeys.
    | >>
    | >> What is the strategy to use in order to accomplish list? (Pointers to
    | >> tech articles would be very helpful, as I'm not even sure where to
    | >> start)
    | >>
    | >> TIA,
    | >>
    | >> geo
    | >>
    | >
    | >
    |
    |
    |
    Steven Cheng[MSFT], Jan 23, 2006
    #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. DC
    Replies:
    1
    Views:
    2,309
  2. Replies:
    2
    Views:
    501
    my$.02
    May 30, 2006
  3. Replies:
    0
    Views:
    1,667
  4. Nathan Sokalski

    Retrieving values from dynamically added controls

    Nathan Sokalski, Sep 9, 2007, in forum: ASP .Net
    Replies:
    7
    Views:
    1,235
    Scott Roberts
    Nov 20, 2007
  5. Replies:
    0
    Views:
    124
Loading...

Share This Page