How to Update the Value of an ASP.NET Textbox Control on a Click Event

1k Views Asked by At

I have three asp.net textbox and button on my asp.net webform

namely textbox1, textbox2, textbox3, button1

i want if integer value of textbox2 will be substracted from textbox1 then result will be displayed in textbox3 and textbox1 and textbox2 value will remain the same ....on buttonclick event ...

MY PROBLEM :

ya i know ... how to do that .... my actually problem was that ... when i click button the text in textbox1 and textbox2 and textbox3 will be disappear ... but it want it remains the same

3

There are 3 best solutions below

0
smartcaveman On

You need to subscribe the Button.OnClientClick to an event handler that does something like textbox3.Text = (int.Parse(textbox1.Text)-int.Parse(textbox2.Text)).ToString();

0
Mukesh On

Check whether you have enabled the "ViewState" for the controls or page. And confirm that you have no initialization for the text box value.

0
AudioBubble On

Are they dynamic controls? If yes, try to recreate them in page_load.