HighTechTalks DotNet Forums  

Adding property to TextBox

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Adding property to TextBox in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jason Barnett
 
Posts: n/a

Default Adding property to TextBox - 08-31-2010 , 03:07 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?

Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: Adding property to TextBox - 09-21-2010 , 07:55 AM






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 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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?

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.