[lnkForumImage]
TotalShareware - Download Free Software

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


 

Jason Barnett

8/31/2010 8:07:00 PM

I have created a WebControl that inherits from TextBox. I would like to add
a property to it that stores/retrieves a ViewState value, so the value is
persisted upon postback.

As an attempt to accomplisth this, I've added a HiddenField control to the
Controls collection during CreateChildControls. At the client, I have
JavaScript that updates the hidden value. On postback, I retrieve the value
during LoadPostData, like so

Text = postCollection[this.UniqueID + "_HiddenFld"];

Thought there might be a better way to accomplish this though. I'm worried
that the value may not always be persisted for some reason. Is there a
better way of doing this?
1 Answer

darth_small

9/21/2010 12:56:00 PM

0

have you tried..

reading text in the webpage, then changing it's state with an if.. else
statement.... use the text itself as the toggle flag

hope this helps.. just learned that trick the other day.. still a newbie
tho..



"Jason Barnett" <JasonBarnett@discussions.microsoft.com> wrote in message
news:24FD0D29-5ED8-4B95-BB25-E1B22BA449D8@microsoft.com...
> I have created a WebControl that inherits from TextBox. I would like to
> add
> a property to it that stores/retrieves a ViewState value, so the value is
> persisted upon postback.
>
> As an attempt to accomplisth this, I've added a HiddenField control to the
> Controls collection during CreateChildControls. At the client, I have
> JavaScript that updates the hidden value. On postback, I retrieve the
> value
> during LoadPostData, like so
>
> Text = postCollection[this.UniqueID + "_HiddenFld"];
>
> Thought there might be a better way to accomplish this though. I'm
> worried
> that the value may not always be persisted for some reason. Is there a
> better way of doing this?