[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Retrieving contained Controls during postback using LoadPostData

Nathan Sokalski

9/27/2007 2:58:00 AM

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
njsokalski@hotmail.com
http://www.nathansok...


5 Answers

Teemu Keiski

9/27/2007 3:53:00 PM

0

Hi,

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

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice....
http://teemu...


"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:OrXChILAIHA.1168@TK2MSFTNGP02.phx.gbl...
>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
> njsokalski@hotmail.com
> http://www.nathansok...
>


Nathan Sokalski

9/27/2007 4:23:00 PM

0

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
njsokalski@hotmail.com
http://www.nathansok...
"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:uedY%235RAIHA.4752@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> Control's UniqueID property is usually used as key in form post
> collection.
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice....
> http://teemu...
>
>
> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
> news:OrXChILAIHA.1168@TK2MSFTNGP02.phx.gbl...
>>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
>> njsokalski@hotmail.com
>> http://www.nathansok...
>>
>
>


Teemu Keiski

9/27/2007 4:26:00 PM

0

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....
http://teemu...


"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:u5qKnKSAIHA.748@TK2MSFTNGP04.phx.gbl...
> 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
> njsokalski@hotmail.com
> http://www.nathansok...
> "Teemu Keiski" <joteke@aspalliance.com> wrote in message
> news:uedY%235RAIHA.4752@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> Control's UniqueID property is usually used as key in form post
>> collection.
>>
>> --
>> Teemu Keiski
>> AspInsider, ASP.NET MVP
>> http://blogs.aspadvice....
>> http://teemu...
>>
>>
>> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
>> news:OrXChILAIHA.1168@TK2MSFTNGP02.phx.gbl...
>>>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
>>> njsokalski@hotmail.com
>>> http://www.nathansok...
>>>
>>
>>
>
>


Teemu Keiski

9/27/2007 4:29:00 PM

0

Note: if you access Control instance directly, call EnsureChildControls
before that


"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:%23lyFlMSAIHA.5960@TK2MSFTNGP05.phx.gbl...
> 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....
> http://teemu...
>
>
> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
> news:u5qKnKSAIHA.748@TK2MSFTNGP04.phx.gbl...
>> 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
>> njsokalski@hotmail.com
>> http://www.nathansok...
>> "Teemu Keiski" <joteke@aspalliance.com> wrote in message
>> news:uedY%235RAIHA.4752@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> Control's UniqueID property is usually used as key in form post
>>> collection.
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice....
>>> http://teemu...
>>>
>>>
>>> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
>>> news:OrXChILAIHA.1168@TK2MSFTNGP02.phx.gbl...
>>>>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
>>>> njsokalski@hotmail.com
>>>> http://www.nathansok...
>>>>
>>>
>>>
>>
>>
>
>


Nathan Sokalski

9/27/2007 9:55:00 PM

0

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
njsokalski@hotmail.com
http://www.nathansok...

"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:%23lyFlMSAIHA.5960@TK2MSFTNGP05.phx.gbl...
> 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....
> http://teemu...
>
>
> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
> news:u5qKnKSAIHA.748@TK2MSFTNGP04.phx.gbl...
>> 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
>> njsokalski@hotmail.com
>> http://www.nathansok...
>> "Teemu Keiski" <joteke@aspalliance.com> wrote in message
>> news:uedY%235RAIHA.4752@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> Control's UniqueID property is usually used as key in form post
>>> collection.
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice....
>>> http://teemu...
>>>
>>>
>>> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
>>> news:OrXChILAIHA.1168@TK2MSFTNGP02.phx.gbl...
>>>>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
>>>> njsokalski@hotmail.com
>>>> http://www.nathansok...
>>>>
>>>
>>>
>>
>>
>
>