Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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>

Posted
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'

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...