tags:

views:

60

answers:

2

I have a TextBox(enabled with PostBack). I need to store the value of it before it's postback. Is it possible? If so, can you please tell me how?

Eg : I enter "10" in my TextBox. Then, in it's PostBack, a message box appears, telling "You have entered Ten!". Next, I enter "100" in my TextBox, this time, a message box appears and tells, "You have not entered the correct number!". Upto this point, it's Okay. But now what I need is, when I press the Okay button in the second mentioned message box, the number "10" should be displayed in the TextBox.

Thanks in advance!

A: 

Sounds like a job for JQuery. Copy your textbox value in a hidden field whenever the change event fires.

$("#myTextBoxId").change(function() { $(#myHiddenFieldId).val(this.value)});
VdesmedT
+4  A: 

Hello,

For this you can store data into Session object.It will contain your value after the post back as well.

Assign a textbox value->

Session["txtvalue"]=Textbox1.Text;

for retrieving data

string value=Session["txtvalue"].Tostring();

I hope it will helpful for you............

PrateekSaluja