473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Mouseover effect on imagebutton

I'm an ASP newbie and have just started experimenting with ASP.NET 2.0 using
the VS.NET 2005 Beta. As a starting point I have used the 'Personal WEB
site' starter kit.

I am now trying to figure out how to make my image buttons come 'alive' with
a mouseover effect. I am used to DHTML and using the mouseover event to
change the bitmap. But what is the correct/best way to do this in ASP.NET ?
Any experienced ASP.NET people who would care to give me some hints here ?

Thanks!
Bendik
Nov 19 '05 #1
2 17687
Hi!

Here is the complete solution:
<asp:ImageButton ID="ibImage" ImageUrl="~/b.jpg" runat="server" />

[...]

protected void Page_Load(object sender, EventArgs e)
{
ibImage.Attributes.Add("onmouseover", "this.src='s.jpg'");
ibImage.Attributes.Add("onmouseout", "this.src='b.jpg'");
}

--
C# Dev
"Bendik Engebretsen" wrote:
I'm an ASP newbie and have just started experimenting with ASP.NET 2.0 using
the VS.NET 2005 Beta. As a starting point I have used the 'Personal WEB
site' starter kit.

I am now trying to figure out how to make my image buttons come 'alive' with
a mouseover effect. I am used to DHTML and using the mouseover event to
change the bitmap. But what is the correct/best way to do this in ASP.NET ?
Any experienced ASP.NET people who would care to give me some hints here ?

Thanks!
Bendik

Nov 19 '05 #2
Thanks Jacek!

This is a little embarassing, but I am so new to ASP.NET that
I couldn't figure out how to use your solution in my project. I tried adding
a Page_Load handler to my Default.aspx.cs file like this

void Page_Load(object sender, EventArgs e)
{
LoginButton.Attributes.Add("onmouseover",
"this.src='Images/button-login_hot.gif'");
LoginButton.Attributes.Add("onmouseout",
"this.src='Images/button-login.gif'");
}

but apparently the LoginButton ID is not recognized here.

As I said I am using ASP.NET 2.0 and the 'Personal WEB site' starter kit as
a base. Maybe the structure is different and I don't understand the whole
story here ?

Anyway, I tried a slightly different approach: I tried adding the
onmouseover and onmouseout events in my .skin file (new ASP.NET 2.0
feature!) like this:

<asp:imagebutton runat="server" Imageurl="Images/button-login.gif"
onmouseover="this.src='Images/button-login_hot.gif'"
onmouseout="this.src='Images/button-login.gif'" skinid="login"/>

Something now happens when I move the cursor over the 'login' button, but I
don't get the correct image - I just get a frame, a red X and the name of
the button 'login'. It seems the image is not found. What could be wrong ?

Bendik

"Jacek Stawicki" <Ja***********@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
Hi!

Here is the complete solution:
<asp:ImageButton ID="ibImage" ImageUrl="~/b.jpg" runat="server" />

[...]

protected void Page_Load(object sender, EventArgs e)
{
ibImage.Attributes.Add("onmouseover", "this.src='s.jpg'");
ibImage.Attributes.Add("onmouseout", "this.src='b.jpg'");
}

--
C# Dev
"Bendik Engebretsen" wrote:
I'm an ASP newbie and have just started experimenting with ASP.NET 2.0
using
the VS.NET 2005 Beta. As a starting point I have used the 'Personal WEB
site' starter kit.

I am now trying to figure out how to make my image buttons come 'alive'
with
a mouseover effect. I am used to DHTML and using the mouseover event to
change the bitmap. But what is the correct/best way to do this in ASP.NET
?
Any experienced ASP.NET people who would care to give me some hints here
?

Thanks!
Bendik

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: al | last post by:
Hi, I've been trying to create a image mouseOver effect using CSS - is this possible? Or will I have to use DIV tags or something along those lines? I've tried a number of things - the code...
1
by: ACaunter | last post by:
Hi there, I have an ASP.NET page with 4 imagebuttons on the left and 1 big image in the middle.. i need to get a mouseover effect which changes the big middle picture everytime the mouse rolls...
2
by: Dariusz Tomon | last post by:
Hi I got task to make my application much more attractive :( First of all I have to add hover (mouseover) effect to several buttons - imagebuttons - I only know manner with Java Script - but it...
3
by: Annette Acquaire | last post by:
I have and image map with a dozen hotspot links on it that I'm trying to get to open a new image over existing one on mouseover of each COORD. The only thing I was able to do was swap image on...
10
by: tomasio | last post by:
Dear Pros, How can I achieve a nicer hover-effect for the image tomasio.design on the bottom-right of my webpage? I am using the class ".footer a:hover" for a CSS-based mouseover-effect but this...
1
by: tomasio | last post by:
Dear Pros, How can I achieve a nicer hover-effect for the image "tomasio.design" on the bottom-right of my webpage? I am using the class ".footer a:hover" for a CSS-based mouseover-effect but...
2
Steve Kiss
by: Steve Kiss | last post by:
Is there a way to add javascript functionality, onmouseover to be specific, to an image defined with <asp:Image />?
1
by: rupak | last post by:
I have an mouseover effect with css on hover, which change the image on hover through Css. It works with IE fine but have problem with Mozilla, as the background image not coming full on hover. If...
2
by: AndrewC | last post by:
I am using the Scriptaculous/Prototype libraries to build a project and I really want to have an effect like the mootools download page (http://www.mootools.net/download) where when you mouse over...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.