473,549 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In asp event occurs once for textbox.textcha nged AND button.button

I have a textbox and a button on my asp.net form. I have some Smtp code in my
button click procedure. When the user hits the return for the textbox the
button procedure runs. When the button is clicked the button procedure also
runs. This fine so I get the Smtp code to run either way. The problem is that
the user sometimes hits return AND clicks the "submit" button so the Smtp
code gets executed twice. Should I use Application state and a boolean to
make sure that the Smtp code only runs once?

I tried the various events and assigning them to each of the the textbox
changed and button click, but I could find the correct combination. Even if
no event is assigned to the textchanged or button click the code Smtp code
runs when the two events occur so I don't know the easy way around this. Help!

Thanks
--
Spencer
Nov 19 '05 #1
1 2012
Maybe disable the button on post back to that method?

Jason Lind

"Spencer H. Prue" wrote:
I have a textbox and a button on my asp.net form. I have some Smtp code in my
button click procedure. When the user hits the return for the textbox the
button procedure runs. When the button is clicked the button procedure also
runs. This fine so I get the Smtp code to run either way. The problem is that
the user sometimes hits return AND clicks the "submit" button so the Smtp
code gets executed twice. Should I use Application state and a boolean to
make sure that the Smtp code only runs once?

I tried the various events and assigning them to each of the the textbox
changed and button click, but I could find the correct combination. Even if
no event is assigned to the textchanged or button click the code Smtp code
runs when the two events occur so I don't know the easy way around this. Help!

Thanks
--
Spencer

Nov 19 '05 #2

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

Similar topics

8
4302
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender,...
3
2261
by: tfs | last post by:
I have a small page I am using to play around with events and am confused why the "onTextChanged" event doesn't fire until I press the button? I am trying to allow the user to put something in Textbox 1 and then when they exit it, have the event fire to make the Textbox 2 = TextBox 1. Why doesn't it happen right away? And what would be...
2
3967
by: Owin | last post by:
Hi all, I've created an User control. It's an extension of a textbox wich has some extra properties so that validation becomes a lot faster. The control wordks great if autopostback is on. When there's a value in the textbox, the (overridden) textchanged event fires and validation is performed. Now I want to turn off autopostback. So I...
4
4014
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code ontop of the webform1: Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code "
1
4491
by: Samuel Chan | last post by:
I used the textchanged event of textbox and set the autopostback property to true. The textchanged event should fire when the content of the textbox is changed and user tab out of the textbox control. However, textchanged event fires whenever there is a postback, even when I click a button that send postback. Can anybody tell we what change I...
3
3426
by: vvenk | last post by:
Hello: I came across the following code in C# that adds a custom event handler for triggering the click event on a button: System.Web.UI.WebControls.Button button; object buttonOnTab1 = this.UltraWebTab1.Tabs.GetTab(0).FindControl("Button1"); if(buttonOnTab1 != null) {
3
4258
by: Robert W. | last post by:
I'm new to ASP.net programming so excuse my ignorance if the following question seems overly simplistic. I've created a simple Login form with 3 primary WebControls: - A TextBox for the Username - A TextBox for the Password - A Button labelled "Submit" If the user enters a correct username/password combination then he's taken to another...
5
5238
by: S_K | last post by:
This is a weird problem.. I have a page with a textbox and a button (along with a bunch of other stuff). Both the textbox and the button have their SEPERATE events defined for the textchanged and click events. When I change the text in the textbox the textchanged event is called as expected. But the button click event is also called!? ...
1
4011
by: nupuragr82 | last post by:
I have a parent form and on button click I am calling a child page where i have a textbox and a button. On button click of child form I am passing the value of the Textbox to the Textbox in parent page and now I want to fire an event. Button click event on parent page- parameter is txtBlank (TextBox in parent page) function SetRange(Src) ...
0
7518
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...
0
7956
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
7469
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...
0
6040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5087
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
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
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
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
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.