onclick event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I'm creating a web page where I use a rollover function on a html image. Can i associate the onclick event of this client control with a C# function resident on the aspx.cs file
Thank you
Fabrizio
 
Hi,

You should be able to do it, use a ImageButton for that, then you have to
add the needed attributes using Control.Attributes like this :
theImageButton.Attributes.Add( "OnMouseOver","MethodToCall" );

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Fabrizio said:
Hi,
I'm creating a web page where I use a rollover function on a html image.
Can i associate the onclick event of this client control with a C# function
resident on the aspx.cs file?
 
Hi
Unfortunately I already tried this, but doesn't work, it doesn't recognize the OnmouseOver even
Any other way to create a rolover effect
thank you
Fabrizio
 
Hi Fabrizio,

IT does work, Please note that the onmouseover is a client event, not a
serverside event
try this code:

in aspx file:
<asp:imagebutton runat="server" ImageUrl="images/b_addnew.gif"
ID="Imagebutton1" />

in code behind:
protected System.Web.UI.WebControls.ImageButton Imagebutton1;

private void Page_Load(object sender, System.EventArgs e)
{
Imagebutton1.Attributes.Add("onmouseover","alert(1);");
}

It will show you an alert each time u pass over it.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Fabrizio said:
Hi,
Unfortunately I already tried this, but doesn't work, it doesn't
recognize the OnmouseOver event
 
Fabrizio said:
Hi,
I'm creating a web page where I use a rollover function on a html image. Can i associate the onclick event of this client control with a C# function resident on the aspx.cs file?
Thank you,
Fabrizio

What I do is put the image in an IMG tag and then put that inside an ASP
button.

I put the onMouseOver functions in the IMG tag.

The onClick of the button ( which contains the image ) is in the
codebehind ( cs ).
 
Back
Top