Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retrieving contained Controls during postback using LoadPostData

Reply
Thread Tools

Retrieving contained Controls during postback using LoadPostData

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-27-2007
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.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      09-27-2007
Hi,

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

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


"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-27-2007
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/
"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:uedY%(E-Mail Removed)...
> Hi,
>
> Control's UniqueID property is usually used as key in form post
> collection.
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      09-27-2007
Does your control create child controls in CreateChildControls?. That way
you ensure controls are there when you access the Controls collection.


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


"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
> "Teemu Keiski" <(E-Mail Removed)> wrote in message
> news:uedY%(E-Mail Removed)...
>> Hi,
>>
>> Control's UniqueID property is usually used as key in form post
>> collection.
>>
>> --
>> Teemu Keiski
>> AspInsider, ASP.NET MVP
>> http://blogs.aspadvice.com/joteke
>> http://teemukeiski.net
>>
>>
>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>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.
>>> --
>>> Nathan Sokalski
>>> (E-Mail Removed)
>>> http://www.nathansokalski.com/
>>>

>>
>>

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      09-27-2007
Note: if you access Control instance directly, call EnsureChildControls
before that


"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Does your control create child controls in CreateChildControls?. That way
> you ensure controls are there when you access the Controls collection.
>
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>> "Teemu Keiski" <(E-Mail Removed)> wrote in message
>> news:uedY%(E-Mail Removed)...
>>> Hi,
>>>
>>> Control's UniqueID property is usually used as key in form post
>>> collection.
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice.com/joteke
>>> http://teemukeiski.net
>>>
>>>
>>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>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.
>>>> --
>>>> Nathan Sokalski
>>>> (E-Mail Removed)
>>>> http://www.nathansokalski.com/
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-27-2007
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Does your control create child controls in CreateChildControls?. That way
> you ensure controls are there when you access the Controls collection.
>
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>> "Teemu Keiski" <(E-Mail Removed)> wrote in message
>> news:uedY%(E-Mail Removed)...
>>> Hi,
>>>
>>> Control's UniqueID property is usually used as key in form post
>>> collection.
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice.com/joteke
>>> http://teemukeiski.net
>>>
>>>
>>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>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.
>>>> --
>>>> Nathan Sokalski
>>>> (E-Mail Removed)
>>>> http://www.nathansokalski.com/
>>>>
>>>
>>>

>>
>>

>
>



 
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 contained Controls during postback using LoadPostData Nathan Sokalski ASP .Net Building Controls 5 09-27-2007 09:55 PM
System.OverflowException during IPostBackDataHandler.LoadPostData Nathan Sokalski ASP .Net 4 07-21-2006 06:44 PM
System.OverflowException during IPostBackDataHandler.LoadPostData Nathan Sokalski ASP .Net Building Controls 4 07-21-2006 06:44 PM
Web User Controls: Exposing Items property of contained controls Warped ASP .Net Web Controls 2 07-15-2005 01:58 PM
LoadPostData not being called at the right time for controls dynamically added at page load Sam ASP .Net 2 04-26-2004 07:19 AM



Advertisments