Amadelle,
If all of the buttons are of the same type then you can cast sender as the button directly like this:
Dim MyButton As Button = CType(sender, Button)
Then you can tell which button was clicked like this:
Select Case MyButton.ID
Case "MyButton1"
'---Do Something
Case "MyButton2"
'---Do Something Else
End Select
If you have different types of buttons you'll need to find out which type you're dealing with first before you may cast:
Select Case sender.GetType.ToString
Case "System.Web.UI.WebControls.ImageButton"
'---Cast to image button here
Case "System.Web.UI.WebControls.LinkButton"
'---Cast to link button here
End Select
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Amadelle" <am******@yahoo.com> wrote in message news:O$**************@TK2MSFTNGP12.phx.gbl...
Hi all and thanks in advance,
I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if statement like as follows in the PageLoad:
private void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
//do something here
} else {
if (btnSave.clicked)
//do something here
else
//do something else
}
I have my methods btnSave_Click and other buttons setup. It is just that when the buttons are clicked they still go through the Page load event and within the pageload event I need to differentiate which one of the buttons are clicked since it is essential to my code.
Am I crazy for wanting to do something like this? It was very easy to do before with ASP?
Thanks for your input!