HighTechTalks DotNet Forums  

text box value does not match value on postback

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss text box value does not match value on postback in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
allan.palmer@cit.com
 
Posts: n/a

Default text box value does not match value on postback - 12-21-2007 , 01:38 PM






Hi All,

I have a text box that is currently being set by a javascript function
as a running total. the javascript is working fine, as values are
changing the running total is being set correctly in the text box.
When the page is posted to the button OnClick event, the value of the
text box is what was previously defaulted as part of the Page_Load
event.

Any ideas on what is happening here or how to fix this issue?

Thanks ALOT in advance.

Reply With Quote
  #2  
Old   
Mark Rae [MVP]
 
Posts: n/a

Default Re: text box value does not match value on postback - 12-21-2007 , 01:43 PM






<allan.palmer (AT) cit (DOT) com> wrote


Quote:
Any ideas on what is happening here or how to fix this issue?
Show your code...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
  #3  
Old   
Scott Roberts
 
Posts: n/a

Default Re: text box value does not match value on postback - 12-21-2007 , 02:03 PM




<allan.palmer (AT) cit (DOT) com> wrote

Quote:
Hi All,

I have a text box that is currently being set by a javascript function
as a running total. the javascript is working fine, as values are
changing the running total is being set correctly in the text box.
When the page is posted to the button OnClick event, the value of the
text box is what was previously defaulted as part of the Page_Load
event.

Any ideas on what is happening here or how to fix this issue?

Thanks ALOT in advance.
Hi Allan,

The "problem" is that the POST value of the textbox is set *before*
Page_Load, then you are putting a default value in there during Page_Load
(overwriting the POST value), then your button click event is fired and you
see the Page_Load value instead of the POST value.

In your Page_Load, only set the default value of the textbox on the initial
page load:

if (!IsPostBack)
{
// Set default value.
}



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 - 2008, Jelsoft Enterprises Ltd.