10 Replies - 1399 Views - Last Post: 27 April 2011 - 07:08 PM Rate Topic: -----

#1 memoisme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 27-April 11

i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 04:29 AM

 protected void Button3_Click(object sender, EventArgs e)
        {
          
            SqlCommand cmd = new SqlCommand("InfoForSignup", con);
            SqlParameterCollection sqparam = cmd.Parameters;
            cmd.CommandType = CommandType.StoredProcedure;
            sqparam.AddWithValue("@UserName", TextBox3.Text);
            sqparam.AddWithValue("@Password", TextBox4.Text);
            sqparam.AddWithValue("@Email_id", TextBox6.Text);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
        }
       


Is This A Good Question/Topic? 0
  • +

Replies To: i am not able to hit the event handler of a button click?

#2 helperhawk321  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 27
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 04:56 AM

Insert this

handles Button3.click
so it becomes like this
 protected void Button3_Click(object sender, EventArgs e) handles Button3.click
        {
          ...
            
        }




Was this post helpful? Then Click on + at the bottom of this post for me
Was This Post Helpful? -1
  • +
  • -

#3 memoisme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:10 AM

View Posthelperhawk321, on 27 April 2011 - 04:56 AM, said:

Insert this

handles Button3.click
so it becomes like this
 protected void Button3_Click(object sender, EventArgs e) handles Button3.click
        {
          ...
            
        }




Was this post helpful? Then Click on + at the bottom of this post for me

hey this is not working...
Was This Post Helpful? 0
  • +
  • -

#4 Vishu Sukhdev  Icon User is offline

  • D.I.C Head

Reputation: 38
  • View blog
  • Posts: 150
  • Joined: 19-February 10

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:21 AM

Insert this code into your Button Design onclick="Button3_Click"
eg.
 <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Button" />


Was This Post Helpful? 0
  • +
  • -

#5 helperhawk321  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 27
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:23 AM

check your the web form that the button is found(the .aspx file).
make sure you have this onclick="Button3_Click" in the button html tag.

So the code for the button tag should be like this below
<asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="..."/>


Was This Post Helpful? 0
  • +
  • -

#6 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:28 AM

can you post the page that has the button in it?

If worst comes to worst, copy the code for the button, delete the button from the aspx page and the eventhandler from the .cs page and recreate it. Then paste the copied code back into the event handler after it's recreated. Sometimes the connections between controls and their events get broken, I haven't figured out why yet, but usually removing that control and creating a new one fixes it for me.
Was This Post Helpful? 0
  • +
  • -

#7 helperhawk321  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 27
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:41 AM

I agree with Nakor
Was This Post Helpful? 0
  • +
  • -

#8 memoisme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 06:12 AM

how to prepopulate the value in textbox?

View PostNakor, on 27 April 2011 - 05:28 AM, said:

can you post the page that has the button in it?

If worst comes to worst, copy the code for the button, delete the button from the aspx page and the eventhandler from the .cs page and recreate it. Then paste the copied code back into the event handler after it's recreated. Sometimes the connections between controls and their events get broken, I haven't figured out why yet, but usually removing that control and creating a new one fixes it for me.


i alredy paste it..
Was This Post Helpful? 0
  • +
  • -

#9 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 07:21 AM

no you pasted the event handler code, I'm asking for the page where the button is created, which is the .aspx page not the .cs page

This post has been edited by Nakor: 27 April 2011 - 07:22 AM

Was This Post Helpful? 0
  • +
  • -

#10 BrairMoss  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 81
  • Joined: 13-April 10

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 05:04 PM

Memoisme,

Please make sure that when you click on the button in designer view, and check the property panels that the onclick Event is selected to be your button3_Click. If this is not the case make sure to fix it.

You can also place a break point into the button to make sure that it is indeed being clicked.

A little piece of added advice, having multiple controls, such as "button1, button2, button3" can make errors like these very hard to debug. Renaming the button that submits a form to the database to say "btnSubmitForm" allows for easier debugging.

A last piece, to avoid nasty ASP error pages, and yes I know the yellow pages are so awesome to look at, you should place a try/catch/finally block around all areas that require a database connection.


//BrairMoss
Was This Post Helpful? 0
  • +
  • -

#11 memoisme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 27-April 11

Re: i am not able to hit the event handler of a button click?

Posted 27 April 2011 - 07:08 PM

okay but in my case cause validation are true on the page so thats y its not hitting the event hadler of the button.any ways thaks for the advice:-)

i catch my fault.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1