G
Guest
In VS.NET using C# I have an aspx page with many buttons. I need to know which button was pressed and then take actions from there.
In the button's click event I can determine which specific button was pressed by using:
System.Web.UI.WebControls.Button)sender).ID.tostring(); to get the name of the button.
If however. I want to assign a varible by using:
System.Web.UI.WebControls.Button WhichButton = (System.Web.UI.WebControls.Button)Convert.ChangeType_(((System.Web.UI.WebControls.Button)sender).ID,typeof(System.Web.UI.WebControls.Button));
I am able to compile but I throw a run time error of Invalid Cast. How can I cast the button ?
Thanks for your help.
Jim
In the button's click event I can determine which specific button was pressed by using:
System.Web.UI.WebControls.Button)sender).ID.tostring(); to get the name of the button.
If however. I want to assign a varible by using:
System.Web.UI.WebControls.Button WhichButton = (System.Web.UI.WebControls.Button)Convert.ChangeType_(((System.Web.UI.WebControls.Button)sender).ID,typeof(System.Web.UI.WebControls.Button));
I am able to compile but I throw a run time error of Invalid Cast. How can I cast the button ?
Thanks for your help.
Jim