473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text box value does not match value on postback

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.
Dec 21 '07 #1
2 1454
<al**********@c it.comwrote in message
news:97******** *************** ***********@e4g 2000hsg.googleg roups.com...
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

Dec 21 '07 #2

<al**********@c it.comwrote in message
news:97******** *************** ***********@e4g 2000hsg.googleg roups.com...
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.
}

Dec 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2473
by: Steve S | last post by:
Heres what I want to do...User types into a texbox, clicks a button, the button saves that text to a file. The problem is that when I click the submit button, any changes made to the textbox are lost, and it reloads what was previously there. Any ideas? try {
3
2794
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image file differently. In both cases, the setup for the problem is: 1. Create a form with an ImageButton whose ImageURL is invalid, specify an...
3
2069
by: Michael Loughry | last post by:
I'm working for a company in Houston developing a web application. At one point in the code, we have to refresh the page, but save what checkboxes have been selected. Since these checkboxes are created programmatically according to configuration files, they cannot be asp checkboxes. To do this, before refreshing I save which checkboxes are...
19
3472
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2....
16
5130
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString Page.FindControl("tdInput").Controls.Add(txtTest) This successfully creates a textbox called "txtLeft1" in the table
18
2105
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the SelectedIndex to -1. Do you have any suggestion for getting around this problem?
0
3011
by: dcollier9 | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View
1
4187
by: =?Utf-8?B?RG9uem8=?= | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View Source, but I cannot see it using an alert,
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.