473,509 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox and OnTextChanged

Hi. I'm working on an intranet application that requires a user to input
information about themselves. I have a user control with a couple of
textboxes that I want the user to enter their weight into. One is for
Lbs and one is for kg and I'm using the OnTextChanged event to populate
the other control if one is filled in (converting between kg and Lbs).

It works, but when one TextBox is changed and it sets the other's value,
the second TextBox's OnTextChanged event fires too. I'd like to force
only the one one being typed into to fire because with rounding
involved, it may change the text just entered.

So basically, I want to ensure only one postback when the text is
changed in a TextBox and I'm currently getting two because both controls
fire their OnTextChanged events.

Thanks!

Matt
Nov 19 '05 #1
4 7374
Do you have to round it? What type is it, an integer?

Nov 19 '05 #2
You don't have AutoPostBack set to True for these controls do you?
"MattB" <so********@yahoo.com> wrote in message
news:3p************@individual.net...
Hi. I'm working on an intranet application that requires a user to input
information about themselves. I have a user control with a couple of
textboxes that I want the user to enter their weight into. One is for Lbs
and one is for kg and I'm using the OnTextChanged event to populate the
other control if one is filled in (converting between kg and Lbs).

It works, but when one TextBox is changed and it sets the other's value,
the second TextBox's OnTextChanged event fires too. I'd like to force only
the one one being typed into to fire because with rounding involved, it
may change the text just entered.

So basically, I want to ensure only one postback when the text is changed
in a TextBox and I'm currently getting two because both controls fire
their OnTextChanged events.

Thanks!

Matt

Nov 19 '05 #3
I do. I thought it was necessary, or does that event work without it...

OK, I just tried it and without AutoPostBack=True, the event doesn't
fire at all. Seems like I need it.

Thanks,
Matt

Scott M. wrote:
You don't have AutoPostBack set to True for these controls do you?
"MattB" <so********@yahoo.com> wrote in message
news:3p************@individual.net...
Hi. I'm working on an intranet application that requires a user to input
information about themselves. I have a user control with a couple of
textboxes that I want the user to enter their weight into. One is for Lbs
and one is for kg and I'm using the OnTextChanged event to populate the
other control if one is filled in (converting between kg and Lbs).

It works, but when one TextBox is changed and it sets the other's value,
the second TextBox's OnTextChanged event fires too. I'd like to force only
the one one being typed into to fire because with rounding involved, it
may change the text just entered.

So basically, I want to ensure only one postback when the text is changed
in a TextBox and I'm currently getting two because both controls fire
their OnTextChanged events.

Thanks!

Matt


Nov 19 '05 #4
The TextChanged event is registered as having happened at the client level,
but the actual event handler code does not fire until the form is posted
back to the server (remember, event handlers are server-side code and
changing the text happens at the client-level).

So, if you have AutoPostBack turned off for both of the textboxes (which is
the default setting), a user can change the text in one or both of the
textboxes and nothing will happen until the form is submitted to the
server.... then the TextChanged event handler for one or both of the
textboxes will fire, but there will just be one postback.

The point of AutoPostBack is that *if* the control is manipulated in any way
(like changing the text in a textbox), then that action will cause a
postback. So, if you have this turned on for both textboxes, changing
either of them will cause a postback, changing both of them will cause 2
postbacks.

So, the answer is to have AutoPostBack turned off for both of them and when
the user is ready for the conversion to happen, they can just hit a Submit
button that will cause one postback to the server and whichever textbox has
been changed will then run its TextChanged event hander.


"MattB" <so********@yahoo.com> wrote in message
news:3p************@individual.net...
I do. I thought it was necessary, or does that event work without it...

OK, I just tried it and without AutoPostBack=True, the event doesn't fire
at all. Seems like I need it.

Thanks,
Matt

Scott M. wrote:
You don't have AutoPostBack set to True for these controls do you?
"MattB" <so********@yahoo.com> wrote in message
news:3p************@individual.net...
Hi. I'm working on an intranet application that requires a user to input
information about themselves. I have a user control with a couple of
textboxes that I want the user to enter their weight into. One is for Lbs
and one is for kg and I'm using the OnTextChanged event to populate the
other control if one is filled in (converting between kg and Lbs).

It works, but when one TextBox is changed and it sets the other's value,
the second TextBox's OnTextChanged event fires too. I'd like to force
only the one one being typed into to fire because with rounding involved,
it may change the text just entered.

So basically, I want to ensure only one postback when the text is changed
in a TextBox and I'm currently getting two because both controls fire
their OnTextChanged events.

Thanks!

Matt



Nov 19 '05 #5

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

Similar topics

2
2954
by: NewToDotNet | last post by:
Hi, I am very new to ASP.NET and web programming in general. I have one issue. I have a Datagrid object with Edit template. In one Datagrid row, I have 1 DropdownList, 1 textbox and 1 readonly...
6
4728
by: Henri | last post by:
Very strange problem : if I write: <asp:TextBox runat="server" id="myBox" /> the control's ViewState stays always empty, so it loses its properties if it's not always displayed. But if I...
5
2579
by: Vi | last post by:
Hello, I want to be able to reload a DropDownList when a TextBox changes its value. So I set the AutopostBack property of the TextBox to true and in the code behind I do something like: ...
2
4122
by: tshad | last post by:
Is there a way to raise an event when a user exits a textbox? I tried OnTextChanged and that doesn't seem to do it. <asp:textbox id="email" TextMode="SingleLine" OnTextChanged="checkRecords"...
3
6007
by: Sandy | last post by:
Hello - I have a page that runs a stored procedure checking for the existence of a name in a database. If it exists, lblMessage returns text indicating same. When a user goes back and clears...
8
5062
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
1
9017
by: OceanBreeze | last post by:
I am using ASP 2.0 and C# I have a TextBox control in .aspx file. <asp:TextBox ID="CityTxt" runat="server"></asp:TextBox> When I click on that text box, I want to trigger onClick event. ...
2
8495
by: | last post by:
I have a gridview with a textbox in an ItemTemplate, as below. The OnTextChanged event fires okay but how do I pass a parameter to it, I get an error when I try "OnTextChanged(""SomeData"")". I...
1
2037
by: madhanmss | last post by:
Hi, i have two textboxes to enter the start and end dates. I am using javascript calendar to populate these text boxes. Based on the chosen date values, i need to filter a treeview control. ...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
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,...
0
7410
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...
1
7067
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...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
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...
0
3215
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...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.