473,776 Members | 1,572 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 7400
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********@yah oo.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=Tr ue, 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********@yah oo.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********@yah oo.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=Tr ue, 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********@yah oo.com> wrote in message
news:3p******** ****@individual .net...
Hi. I'm working on an intranet application that requires a user to input
informatio n 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
2975
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 textbox in Edit mode. I have written OnTextChanged event handler for text box and OnSelectionIndexChanged event handler for dropdownlist. Whenever a text is changed in writable textbox or a selection is changed in DropDownList, I perform calculations...
6
4742
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 write:
5
2608
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: if(IsPostBack) { if( ((TextBox)sender).ID == "myTextBox" ) myDropDownList.DataBind(); }
2
4141
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" Columns="45" runat="server" /> I need to load a dropdownlist after someone enters his email. There would be no button to push. After the user enters his name and email it needs to check a table to see if there are already any record and if so...
3
6031
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 the textbox, I would like the message to disappear, instead of waiting for a return trip to the server. Any suggestions will be greatly appreciated! --
8
5096
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
9091
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. onClick event is not in ASP 2.0 and gives error.
2
8517
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 would also like to pass in the value of column 1. I would also like to be able to get the row the user is on when this event fires. Thank you for your help. <asp:GridView ID="gv" /> <Columns> <asp:BoundField DataField="Col1"...
1
2072
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. The problem is, the ontextchanged event of the textbox is not firing, when the date is chosen from the javascript calendar. If you enter the date directly into the textbox, the event is firing. I need to find out how to fire the ontextchanged...
0
9628
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10289
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.