I've been looking at google for the past few hours, trying to find an issue to a apparently simple problem. I have a UserControl named RolloverLink that basically contains a asp:LinkButton
and a <img />
. I tried setting the OnClick handler like this:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="RolloverLink.ascx.cs" Inherits="Controls.RolloverLink" %>
<asp:LinkButton runat="server" ID="mug" OnClick="propagate"
CausesValidation="false" onmouseout="MM_swapImgRestore()" >
<img runat="server" ID="pug" name="<%# pug.ClientID %>" border="0" />
</asp:LinkButton>
I put a breakpoint in the propagate
method, but it doesnt stop there. The page does post back (it flashes), but the event doesn't get called.
Here's how my code behind looks like:
public partial class RolloverLink : System.Web.UI.UserControl
{
private string _imageRl;
public string Href { get; set; }
public string ImageUp { get { return pug.Src; } set { pug.Src = value; } }
public string ImageRl {
get
{
return _imageRl;
}
set
{
_imageRl = value;
mug.Attributes["onmouseover"] = "MM_swapImage('"+pug.ClientID+"','','"+_imageRl+"',1)";
}
}
public string Alt { get { return pug.Alt; } set { pug.Alt = value; } }
public int Width { get { return pug.Width; } set { pug.Width = value; } }
public int Height { get { return pug.Height; } set { pug.Height = value; } }
public event EventHandler Click
{
add{click += value; }
remove { click -= value; }
}
private event EventHandler click;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Url.AbsolutePath.EndsWith(Href))
ImageUp = ImageRl;
}
protected void propagate(object sender, EventArgs e)
{
EventHandler copy = click;
if (copy != null)
copy(this, EventArgs.Empty);
else
Response.Redirect(Href);
}
}
and this is how i use it on my master page:
<pwc:RolloverLink ID="contacts" Href="Contacts.aspx"
ImageRl="images/M_contacts_rl.png" ImageUp="images/M_contacts_up.png"
Alt="Initech Global : Laurierville, Québec, Canada" Width="61"
Height="17" runat="server" />
Anyone has an idea or a pointer to an idea? Thanks in advance.