Is there a way to perform Click even with code in ASP.net

Hi,

In Visual Basic I can perform the Click event with code using some thing like this:
Button1.PerformClick()
I tried doing the same in ASP.Net Code-behind page but found that it was not supported, does any one know of a way around this?

Thanks
tariqanisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tristan ShortlandCommented:
   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Write("Hello World!")
    End Sub
0
Tristan ShortlandCommented:
The key things here are the signature of the method and the handles clause.
If you're using visual studio 2005 you can just double click the button in design view and it will generate the click method for you...
0
tariqanisAuthor Commented:
Hi TShortland:,

I guess I didn't make myself clear. What I needed was this:
Click on button1 where is code to raise a click event for button2
In other words: instead of asking the user to click on button2 to perform a certain action, I use code to tell button2 to perform the required action.
Sorry if my question was not expressed clearly.

Thanks

0
Tristan ShortlandCommented:
Sorry for the late reply...

you can do this:

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Button1_Click(Nothing, Nothing)
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Write("Hellow world!")
    End Sub
End Class

The first object you pass in can be anything which is a useful way of passing information to the method...

Tristan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tariqanisAuthor Commented:
Thanks a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.