You must Sign In to post a response.
  • Category: ASP.NET

    Button click event get fire automatically

    I have web form with 2 buttons. both button_click have diffrent code . but when i click on first button it also execute the code of second button automatically.
  • #633010
    Can you post the code in both Button click event?


    Best Regards
    Vadivel
    MVP SQL Server

  • #633015
    Hi friend,


    Remove the both click event and add it once again.

    if your aspx page both controls are using same click event like this

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button1_Click" />



    Change it like this

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />



    Thanks & Regards
    G.Renganathan
    Nothing is mine ,Everything is yours!!!

  • #633016
    check the first button event click event in properties window whether it is calling second button click even.
    For more information visit:
    http://www.sqlascent.blogspot.com/
    http://www.dotnetascent.blogspot.com/

  • #633338
    hai Prasad Bhosale
    Both event will occur at same time
    check this code

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.Text = "hai"
    Button2_Click(sender, e)


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    TextBox1.Text += TextBox1.Text
    End Sub


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.