Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Retrieving contained Controls during postback using LoadPostData

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 27 Sep 2007 03:57 GMT
I am writing a Control that inherits from
System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control
renders more than just one inner Control. When a postback occurs, I need to
get the data posted by these inner Controls (by using the postCollection
argument). However, the postDataKey argument gives the key for the id of the
outer Control. When I need to access the value posted by one of the inner
Controls, I have found that I need to enter the id as a literal String for
the key, but this seems a little too simple for me, with all the Controls
that could get created. Is there some property or method that I should be
using to determine the key? Thanks.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Teemu Keiski - 27 Sep 2007 16:52 GMT
Hi,

Control's UniqueID property is usually used as key in form post collection.

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

>I am writing a Control that inherits from
>System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control
[quoted text clipped - 6 lines]
>Controls that could get created. Is there some property or method that I
>should be using to determine the key? Thanks.
Nathan Sokalski - 27 Sep 2007 17:23 GMT
That's what I thought, and what I have used in a previous Control of mine,
but when I try to do that here I am recieving an error that the Control does
not exist. When I did a debug session I found that the value of the Control
was Nothing. Therefore, I cannot get to the UniqueID. Any idea what could be
causing this? Thanks.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

> Hi,
>
[quoted text clipped - 11 lines]
>>with all the Controls that could get created. Is there some property or
>>method that I should be using to determine the key? Thanks.
Teemu Keiski - 27 Sep 2007 17:26 GMT
Does your control create child controls in CreateChildControls?. That way
you ensure controls are there when you access the Controls collection.

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> That's what I thought, and what I have used in a previous Control of mine,
> but when I try to do that here I am recieving an error that the Control
[quoted text clipped - 16 lines]
>>>with all the Controls that could get created. Is there some property or
>>>method that I should be using to determine the key? Thanks.
Teemu Keiski - 27 Sep 2007 17:29 GMT
Note: if you access Control instance directly, call EnsureChildControls
before that

> Does your control create child controls in CreateChildControls?. That way
> you ensure controls are there when you access the Controls collection.
[quoted text clipped - 20 lines]
>>>>some property or method that I should be using to determine the key?
>>>>Thanks.
Nathan Sokalski - 27 Sep 2007 22:55 GMT
Thank you for your help, I should probably be slapping myself in the head
for my mistake: I created the Controls in CreateChildControls, but forgot
the Me.Controls.Add() method! Thanks again for your help.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

> Does your control create child controls in CreateChildControls?. That way
> you ensure controls are there when you access the Controls collection.
[quoted text clipped - 20 lines]
>>>>some property or method that I should be using to determine the key?
>>>>Thanks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.