I'm building a website using ASP and C# and I wanted to know if it's possible to add a custom events to an asp control.
I want to add an OnClick, OnMouseDown, OnMouseUp (etc.) event to <asp:image>.
Is it possible?
Thanks in advance
yes you can do it this way.
HTML
<asp:Image runat="server" ID="Image1" />
CODE BEHIND
protected void Page_Load(object sender, EventArgs e){
this.Image1.Attributes.Add("onmouseup", "alert('this is the OnMouseUp event')");
}
EDIT
It can be do it using DHTML but as you may know
DHTML is the art of combining HTML, JavaScript, DOM, and CSS.
protected void Page_Load(object sender, EventArgs e){
//change the Image Url when the click event fire
this.Image1.Attributes.Add("onclick", "this.src='image1.jpg'");
}