Asp.Net 2.0 - Textbox previous value

S

Steve

How do I get the previous value of a text box ? Is there a way to access
the TextBox control state ?

Thanks for any direction,
Steve
 
M

Mark Rae [MVP]

How do I get the previous value of a text box ? Is there a way to access
the TextBox control state ?

There are some clever tricks you can do with ViewState, but by far the
simplest (and 100% guaranteed) method is to include a hidden field
containing the initial value of the textbox and then compare the two at
postback:

<asp:TextBox ID="MyTextBox" runat="server" Text="Hello" />
<asp:HiddenField ID="MyHiddenTextBox" runat="server" Value="Hello" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top