Skip to content
July 7, 2009 / kiranpatils

How can i click button programmatically?


Q: How can i click button programmatically?

Okay, Some of the experts will say call btn_click(sender,eventargs); You are right expert.. But i would like to do as below:
I have one User control which has : Two Textbox and one button(btnSave) — and one click event associated with it(btnSave_Click).
I have used this control on my page say Default.aspx — Now, From Default.aspx. I would like to call btnSave_Click on one of my button kept on Default.aspx say FinalSave. So experts how can i do this? 😦


Okay, This simple guy have a solution it is as follow:

1. Find button control using FINDCONTROL Method.
Button fondButton = UserControl1.FindControl(“btnSave”);

2. Call Button click using following way:

isn’t it a cool way to call button click??

Thanks to this guy for nice post :


One Comment

Leave a Comment
  1. Bradut Dima / Jun 4 2014 7:04 pm

    Good solution. Please note that, if the button is located on another webpage [and you run this from the BasePage.cs], then that page needs to have “EnableEventValidation = false”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: