0

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

smartcaveman
  • 41,281
  • 29
  • 127
  • 212
pooja
  • 41
  • 1
  • 5
  • 1
    You should pick a title that outlines your problem. – alex Apr 05 '11 at 01:46
  • 1
    You can use basic mathematics. – dotalchemy Apr 05 '11 at 01:47
  • 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 – pooja Apr 05 '11 at 01:53
  • Do you have some kind of initialization code for your textboxes in the the code-behind? If so, you need to wrap that inside of a conditional `If Not Postback`, so that the initialization only happens once. – Joel Lee Apr 05 '11 at 01:57
  • Post some code (and a better title). – Martin Doms Apr 05 '11 at 02:05
  • My doubt is you are using html text input and not the asp.net TextBox. The former will loose value on postback while the latter will retain. – gbs Apr 05 '11 at 03:06

3 Answers3

1

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();

smartcaveman
  • 41,281
  • 29
  • 127
  • 212
0

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

Mukesh
  • 807
  • 3
  • 10
  • 18
-1

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

Connor Low
  • 5,900
  • 3
  • 31
  • 52