I have a button in my aspx file called btnTest. The .cs file has a function which is called when the button is clicked.
btnTest_Click(object sender, EventArgs e)
How can I call this function from within my code (i.e. without actually clicking the button)?
You can call the btnTest_Click just like any other function.
The most basic form would be this:
All above methods are not good because you might change event function name. The easiest is:
You can use reflection to Invoke the
OnClick
method which will fire the click event handlers.I feel dirty posting this but it works...
Inside first button event call second button(imagebutton) event:
you can use the button state such as the imagebutton's commandArgument if you save something into it.
Provided that the method isn't using either of these parameters (it's very common not to.)
To be honest though this is icky. If you have code that needs to be called you should follow the following convention: