MoshiMoshi Posted September 1, 2003 Posted September 1, 2003 I'm wondering if you can change a web controls onclick value from a script. e.g.: <%@ Page Language="C#" %> <script runat="server"> void LoginBtnClick(object sender, ImageClickEventArgs e) { LogBtn.onClick="LogoutBtnClick"; LogBtn.ImageUrl="LogoutBtn.gif"; } </script> <html> <head> </head> <body> <form runat="server"> <asp:ImageButton id="LogBtn" onclick="LoginBtnClick" runat="server" imageUrl="LoginBtn.gif"> </asp:ImageButton> </form> </body> </html> Quote
Moderators Robby Posted September 1, 2003 Moderators Posted September 1, 2003 Why or what are you trying to do? Quote Visit...Bassic Software
MoshiMoshi Posted September 1, 2003 Author Posted September 1, 2003 Why or what are you trying to do? I'm trying to make my loginbutton (ImageButton) transform into a logout button, by editing its onclick value. I can change its ImageUrl value, but the onclick gives me an error. void LoginBtnClick(object sender, ImageClickEventArgs e) { Line 16: LogBtn.onClick="LogoutBtnClick"; Line 17: LogBtn.ImageUrl="LogoutBtn.gif"; Line 18: } Compiler Error Message: CS0117: 'System.Web.UI.WebControls.ImageButton' does not contain a definition for 'onClick' Quote
Moderators Robby Posted September 1, 2003 Moderators Posted September 1, 2003 Just handle both buttons with the same handler Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.