Solved

ASP.net Text change in TextBox triggers button event

Posted on 2016-09-19
5
39 Views
Last Modified: 2016-09-22
Hi. I have a text box that I add using the following code. I have a button on the same page. When I change text in the text box it triggers the click event of the button. I have no idea why this is happening. Why would it

  Dim tb As New TextBox
   tb.ID = oControlName
  tb.CssClass = "xTextBoxHundredPercent"
 Me.Panel_Controls.Controls.Add(tb)

'Here is the markup for the button
  <asp:Button ID="btnSave" runat="server" Text="Button" Width="100%" />

'Here is the click event for the button that gets triggered when the text in the text box added with above code is changed
    Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Call oSave()
    End Sub
0
Comment
Question by:murbro
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
Comment Utility
how did you attached btnSave_Click event to the button?
0
 

Author Comment

by:murbro
Comment Utility
As I said above
'Here is the click event for the button that gets triggered when the text in the text box added with above code is changed
     Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
         Call oSave()
     End Sub
0
 

Author Comment

by:murbro
Comment Utility
The event is triggered when I click Enter. This is Visual Studio 2015 and it wouldn't have happened in visual Studio 2010
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
Comment Utility
It might be that your save button on the page have focus and when you click enter it executes the click event.

Put following code in you text changed event sub

If e.KeyCode = Keys.Enter Then

'do nothing here...

End If

Open in new window

0
 

Author Closing Comment

by:murbro
Comment Utility
Great. Thanks for the help
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now