Solved

ASP.net Text change in TextBox triggers button event

Posted on 2016-09-19
5
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 41804507
how did you attached btnSave_Click event to the button?
0
 

Author Comment

by:murbro
ID: 41804571
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
ID: 41804572
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
ID: 41804593
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
ID: 41811265
Great. Thanks for the help
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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