Any reason for no rollover controls in .NET 2.0?

R

Rob R. Ainscough

Just curious why a VERY commonly used affect of rollover was NOT implemented
in .NET 2.0 for web controls?

Does anyone have a link to VB code that will show me how to build my own
UserControl that will support a rollover?

thanks, Rob.
 
N

Nathan Sokalski

Why there is not a built-in function for it in .NET, I really can't answer,
but here is a very simple function I wrote for myself (I did it using 1.1,
but I can't imagine why it wouldn't work in 2.0). Enjoy!

Public Shared Sub AddRollover(ByVal img As Web.UI.WebControls.Image, ByVal
rollover As String)
'Adds the rollover feature to an Image or ImageButton (or other class
that inherits from an Image)
img.Attributes.Add("onmouseover", "this.src='" & rollover & "';")
img.Attributes.Add("onmouseout", "this.src='" & img.ImageUrl & "';")
End Sub
 
R

Rob R. Ainscough

Thanks for the suggestion/code, I ended up making a UserControl, but was
just curious why such a well used feature was not included in .NET 2.0.

Rob.
 
N

Nathan Sokalski

I'm not sure, but if I had to take a guess I would say they didn't want to
bother making a whole new class for something that can be done with very
little extra code (you saw how short my function was). I think that some of
their goals were:

1. To keep the properties as similar to those in 1.1 as possible
2. I think they wanted the Image Control to mirror the HTML img tag as
closely as possible, and the HTML img tag does not have a built-in rollover
feature
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top