Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retrieving User's Input from Dynamically added WebControls

Reply
Thread Tools

Retrieving User's Input from Dynamically added WebControls

 
 
Dotnet Gruven
Guest
Posts: n/a
 
      01-20-2006
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


 
Reply With Quote
 
 
 
 
Ranjan Sakalley
Guest
Posts: n/a
 
      01-20-2006
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
>



 
Reply With Quote
 
 
 
 
Dotnet Gruven
Guest
Posts: n/a
 
      01-20-2006
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:(E-Mail Removed) m...
>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
>>

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      01-23-2006
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" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<(E-Mail Removed)>
| 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: <#(E-Mail Removed)>
| 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!TK2MSFT NGP10.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:(E-Mail Removed) m...
| >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
| >>
| >
| >
|
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving values from dynamically added controls Nathan Sokalski ASP .Net 7 11-20-2007 03:23 PM
Need help retrieving controls dynamically added to GridView yeltsin27@yahoo.co.uk ASP .Net 0 07-18-2006 02:26 PM
Retrieving dynamically added items on postback echan8@gmail.com ASP .Net 2 05-30-2006 08:57 PM
Using PartialCaching with dynamically added Webcontrols DC ASP .Net 1 06-07-2005 04:29 PM
Dynamically added WebControls requiring TWO clicks to fire event?!? iamurbal@gmail.com ASP .Net Web Controls 0 06-07-2005 03:49 PM



Advertisments