Text Box Text changed firing twice

Has anyone come across this littile problem.

I a using a text box to add quantities to a SQL table. The control is fired under texbox_textchanged. This runs a SQL stored procedure which inserts the data to the table.
The problem is that if the return key is accidently pressed twice or too heavily, it would appear that the event is firing twice, thus doubling the value inserted into the table.
Example of code:
Private Sub txtquantity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtquantity.TextChanged
If txtfactory.Text = "" Then
SetFocus(txtfactory)
Else
SetFocus(txtpartcode)
End If
obJERPManDB.Open()
objdataadaptor = New SqlDataAdapter("hpInsertRecipeData", obJERPManDB)
objdataadaptor.SelectCommand.CommandType = CommandType.StoredProcedure
objdataadaptor.SelectCommand.Parameters.Add(New SqlParameter("@UserName", Session("UserName")))
objdataadaptor.SelectCommand.Parameters("@UserName").Value = Session("UserName")
objdataadaptor.SelectCommand.Parameters.Add(New SqlParameter("@Quantity", txtquantity.Text))
objdataadaptor.SelectCommand.Parameters("@Quantity").Value = txtquantity.Text
objdataadaptor.SelectCommand.Parameters.Add(New SqlParameter("@Factory", txtfactory.Text))
objdataadaptor.SelectCommand.Parameters("@Factory").Value = txtfactory.Text
objdataadaptor.SelectCommand.Parameters.Add(New SqlParameter("@Partcode", txtpartcode.Text))
objdataadaptor.SelectCommand.Parameters("@Partcode").Value = txtpartcode.Text
objdataadaptor.SelectCommand.ExecuteNonQuery()

End Sub
the stored procedure is fairly simple:
CREATE procedure hpInsertRecipeData @UserName char(10),@Quantity decimal,@Factory char(2),@Partcode char(10)
as
if exists (select PartCode from htRecipeData where PartCode = @Partcode and UserName = @UserName)
begin
update htRecipeData
set Quantity = (select Quantity from htRecipeData where PartCode = @Partcode and UserName = @UserName) + @Quantity
where PartCode = @Partcode and UserName = @UserName
end
if not exists (select PartCode from htRecipeData where PartCode = @Partcode and UserName = @UserName)
begin
insert htRecipeData
values (@Partcode,@Factory,@Quantity,@UserName)
end
GO
txtfactory,txtpartcode and txtquantity are all standard text fields.
If I am gentle with the return key on quantity, then only the value entered is put in. I don't want to add another button which would complicate the form for my end users. I have used this successfully on other forms in the past - this is the first time I have had the problem.
regards
Jim Draper
0
jim
5/11/2004 8:36:50 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
1377 Views

Similar Articles

[PageSpeed] 15

Further to the above and after a lot of debugging. It would appear that the data is being stored or cached on the client side for the number of times the enter key is hit. Then the change event is being fired for each cached or stored pieces of data. 

The problem may be that the cached data needs to be cleared out when the event fires the first time or am I simplifying things.
Am I on the right track and if I am how can I do it?
regards

Jim Draper
0
jim
5/11/2004 12:26:10 PM
Reply:

Similar Artilces:

Check if the text box "text" has changed (RePost from web forms forum)
Greetings! How can i know if the "text" inside of a text box has changed? For example, I currently have this: if (txtMU.TextChanged()) { } But this does not work. The other idea I had was to assign the existing value of the text box to a string and then when the user click the save button I can create a conditional statement to compare the original string with the new string. However, I would like something more effective as I have like 12 text boxes to compare. Thanks, EduardoThanks,Please Mark this post as answered if it was helpful. Here is the easiest way that I have ...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

changing the text on text box
hello, i need to build an addon which takes (on mouse click) the text of any given input text box and change it. how do i get theobject of the text box and set my text to its value. thanks... ...

Enabling button after text changed on text box from form view control
I'm using form view to display some text box that contains user's personal info. There are "save" buttons for each text box which are disable as default. I want to enable them when text is changed on the the text box. I don't know how to write the the JavaScript function to do this task and i also don't know how to call the function from the the textbox control (onchange or ontextchange?). Here is the formview code: <asp:FormView ID="FormView1" runat="server" DataSourceID ="personalSQL"> <ItemTemplate > <ta...

How do I block a user from entering text in a text box if they type text in another text box?
I have two text boxes, and want the user to complete one or the other.  How can I "grey out" one text box if a user starts typing in the other textbox?  Never make important decisions on a Monday! You can use the OnTextChanged event of the textboxes and write Javascript for both textboxes to disable the other textbox when the user starts to type in something in one textbox. The only problem with that is that once the user starts to type in something in one text box the other textbox gets disabled and locks up, so now the user HAS TO compulsarily type what he wants in th...

VB .net Web Form will not get contents of Text Box
I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine. I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database. When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will ha...

Passing Text of a text box in child form to a label in parent form
Hi Elite People !! I have a parent form with a number of ASP Labels and Buttons. Each ASP Label has a ASP Button next to it. What I want to acheive is when you click the button, it should open a new window with a ASP multiline text box and a "save" button. User can enter the text in the text box and when they click the SAve button, the Text in the text box of the Child window should be displayed in the label on the parent form.  I am successfully able to do this when I have a Text Box in the Parent form, but my requirement is to use Labels on the Parent Form. I am ...

Text box
I have a Popup calendar that opens when i click on the parent form and, and after selecting date - it fills the parent textbox and closes the popup window. Every thing is working fine, but i have one problem, i want the Textbox - textchanged event to fire when there is a change,(auto postback for textbox is set to true). This is not happening. If i manually type in the date in the textbox and go to other control then it fires, but not when i select date from PopUp. How to make it work Appreciate any response. Thanks. Parent Form JAVASCRIPT function OpenCalendar(...

Text style change on the text box
 Hi experts,I'm try to create an email system, i'm having problem on the compose new email which allow user to change their text style while they press the button, i had been totally out of idea to do it.So please give me any idea and suggestion how to do it... Thanks...Below is the basic of my code:<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="NewPost.aspx.cs" Inherits="_NewPost" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd...

Bold Text For Selected text in Text Box
Hi EveryoneI have a small thing to do [at this time , very big for me]. I want to make some text string as bold which appears in a text box control for the web. It means some of the portion of the string will be bold and some will be in the normal font style. Can anyone suggest any idea to accomplish this task. [I know that we can set the font weight property for the whole text box and all the text appears in the selected font-weight]Any suggestions.BaberBaber SaeedSoftware EngineerPalmChip, Pakistan Toll Free: 0800-000-13 Ext:494Cell: 0300-6438634 Standard TextBox that comes with ASP.NET ...

Text Changed Event For Dynamic Text Box
Hi.. i'm using the Grid View in my Web Application.. I'm creating a TextBox dynamically inside the grid view using Itemplate.. now what my requirement is after entering some values in the Textbox., in the Text_changed event it will do some calculations... But now my problem is i don know how to Write the TextBox_Changed event for the Dynamically created textbox.. pls help me Hi, in ITemplate's implementation of InstantiateIn (where you also create the TB), you could write handler for it tb.TextChanged += new EventHandler(tb_TextChanged); and so on... if you need to write it...

how to call a text changed event in text box
hi all   I am developing a web application. In that i have used a text box and pop up calendar to generate a date time picker. Anyhow its working fine. But when i change the date in the text box, the text changed event is not calling. Also i have done autopostback = true. Can anybody help me regarding this. thanks in advance. hi Sancti, The another way is to write the ontext change event code inside the onselectedchange event of the calendar.Please do not forget to click Mark As Answer on the post that helped you. Regards,K.Sivakumar  Is u added this handler if yes and ...

Is their a way to check if text in a text box has changed?
On a particular web form I wrote, I have a multi line textbox where people enter text/content. When the page loads, it defaults to the text that they had previously entered into the text box. The user then if they wish may change the contents of the text and then press a "save" buttton. I want to do the following: 1. Somehow check if the text in the textbox has changed. If it has changed from the original text, then save the new text to a file. So the big question here is how do I check to see if the text in the textbox has changed. Is their a method call that can do this? Or do ...

text change, why wont you text change!!!!
Hi i've got a huge form with loadsa recordsets that populate text boxes, AND I MEAN LOADS!!!!It involves some calculationsI have text1.text which goes away and changes text2.text which is fine, but in text2.text i have another on text change thingy which it wont call :(any one have any ideas : )also does any one know how i could call a txt change, so it does the call total a. dont know if thats possible as well. Private Sub txtShare_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtShare.TextChanged Call Total_A() End SubThank you if any one one could help...

Web resources about - Text Box Text changed firing twice - asp.net.web-forms

The Day the Universe Changed - Wikipedia, the free encyclopedia
The Day the Universe Changed (subtitled "A Personal View by James Burke") is a British documentary television series written and presented by ...

PMD News Facebook Group Changed to Closed
... that were previously available only to Preferred Marketing Developers were opened to the public in July , but one of them, PMD News , was changed ...

Facebook changed my name to my unknown birth name, not my current legal name... - Facebook-Hilfeforum ...
I provided Facebook with my original birth certificate and my name change certificate - instead they changed my name to my birth name which I ...


Search Twitter - "If I didn't try this my life wouldn't have changed."
Sign in Sign up Search Refresh CHUA Chee Wee @ chuacw 4h If you put " If I didn't try this my life wouldn't have changed ." into your Twitter ...

Changed the AWS instance size on the Trex server from small to large, and now it runs much better. ;-) ...
A bunch of people made suggestions after reading today's Changes piece. The one that made the big difference came from my longtime programming ...

Economics : How has introductory economics changed as it's been taught in American universities over ...
Answer (1 of 5): Introductory economics has not changed enormously over the years. In part this is because much of introductory economics is ...

Changed Priorities Ahead - Flickr - Photo Sharing!
Explore joshinrhodeisland's photos on Flickr. joshinrhodeisland has uploaded 616 photos to Flickr.

IBM Centennial Film: 100 X 100 - A century of achievements that have changed the world - YouTube
The film features one hundred people, who each present the IBM achievement recorded in the year they were born. The film chronology flows from ...

Battle against terrorism: Team Australia approach denies society has changed
The choice between the politics of the old and that of the new is not a choice only faced by Australia. It&rsquo;s faced by the US, by Britain, ...

Resources last updated: 12/24/2015 2:07:27 AM