Rollovers Class
Description
The Rollovers class contains shared methods that add a rollover effect that changes either the image, background color, or height and/or width of a WebControl or HtmlControl. Several of these shared methods are available as Extension Methods in the ControlExtensions or ImageExtensions module.
Example
AddRollover(Me.imgNoInitial, "/images/rotatefrog.gif")
This example creates a rollover using the specified image as the rollover image and the ImageUrl or Src property as the initial image.
AddRollover(Me.imgInitial, "/images/rotatefrog.gif", "/images/frog.gif")
This example creates a rollover using the specified images as the rollover and initial images.
AddRolloverBackgroundColor(Me.lblBackground, Drawing.Color.FromArgb(255, 64, 128, 192))
This example creates a rollover that adds and removes a specified background color for a WebControl or HtmlControl.
Background Color Rollover

Background Color Rollover
AddRolloverBackgroundColor(Me.lblBackground, Drawing.Color.FromArgb(255, 64, 128, 192), Drawing.Color.Orange)
This example creates a rollover that changes the background color of a WebControl or HtmlControl between two specified colors.
Background Color Rollover

Background Color Rollover
AddRolloverExpansionHeight(Me.lblHeightSpecific, "75px", "150px")
This example creates a rollover that changes the height of a WebControl or HtmlControl between the specified heights.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
AddRolloverExpansionHeight(Me.lblHeightAuto, "75px")
This example creates a rollover that changes the height of a WebControl or HtmlControl between the specified and default heights.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
AddRolloverExpansionWidth(Me.lblWidthSpecific, "100px", "300px")
This example creates a rollover that changes the width of a WebControl or HtmlControl between the specified widths.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.

I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
AddRolloverExpansionWidth(Me.lblWidthAuto, "100px")
This example creates a rollover that changes the width of a WebControl or HtmlControl between the specified and default widths.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.

I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
AddRolloverExpansion(Me.lblSpecific, "100px", "100px", "150px", "300px")
This example creates a rollover that changes the width and height of a WebControl or HtmlControl between the specified widths and heights.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.

I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
AddRolloverExpansion(Me.lblAuto, "100px", "100px")
This example creates a rollover that changes the width and height of a WebControl or HtmlControl between the specified and default widths and heights.
I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.

I have had an interest in computers as far back as preschool, when my family had an old Texas Instruments computer that looked more like a video game system, but it did allow you to write programs using TI-Basic (a language based mostly on line numbers and goto statements). Although I never learned to do much but teach it to count and display words because I was so young, I did have a strong interest in learning about it. This interest continued to grow when my family purchased our first computer with a floppy disk drive and DOS operating system. As we moved on up through the operating systems as they came, I was soon the first person in my family to move into the Windows 95 era when I got my own computer for the first time. The start of my experiences in programming began while I was in high school with Visual Basic, JavaScript, and HTML. By the time I graduated and started college, I knew that computer science was without question the major I wanted.
Properties & Methods
AddRollover(ByVal img As System.Web.UI.WebControls.Image, ByVal rollover As String) AddRollover(ByVal img As System.Web.UI.WebControls.Image, ByVal rollover As String, ByVal initial As String) AddRollover(ByVal img As System.Web.UI.HtmlControls.HtmlImage, ByVal rollover As String) AddRollover(ByVal img As System.Web.UI.HtmlControls.HtmlImage, ByVal rollover As String, ByVal initial As String)Adds a rollover image to an Image, ImageButton, or HtmlImage using JavaScript.
  • img - The Image, ImageButton, or HtmlImage to add a rollover to
  • rollover - The URL of the rollover image
  • initial - The URL of the original image. If this parameter is not used, the ImageUrl or Src property of the img parameter will be used
AddRolloverBackgroundColor(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal rollover As System.Drawing.Color) AddRolloverBackgroundColor(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal rollover As System.Drawing.Color, ByVal initial As System.Drawing.Color) AddRolloverBackgroundColor(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal rollover As System.Drawing.Color) AddRolloverBackgroundColor(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal rollover As System.Drawing.Color, ByVal initial As System.Drawing.Color)Adds a rollover that changes the background color of a WebControl or HtmlControl
  • ctrl - The WebControl or HtmlControl to add a rollover to
  • rollover - The rollover background color
  • initial - The initial background color. If this parameter is not used, ctrl will only have a background color while the cursor is rolled over it
AddRolloverExpansionHeight(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialheight As String) AddRolloverExpansionHeight(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal expandedheight As String) AddRolloverExpansionHeight(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialheight As String) AddRolloverExpansionHeight(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialheight As String, ByVal expandedheight As String) AddRolloverExpansionWidth(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialwidth As String) AddRolloverExpansionWidth(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialwidth As String, ByVal expandedwidth As String) AddRolloverExpansionWidth(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialwidth As String) AddRolloverExpansionWidth(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialwidth As String, ByVal expandedwidth As String) AddRolloverExpansion(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal initialwidth As String) AddRolloverExpansion(ByVal ctrl As System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal initialwidth As String, ByVal expandedheight As String, ByVal expandedwidth As String) AddRolloverExpansion(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialheight As String, ByVal initialwidth As String) AddRolloverExpansion(ByVal ctrl As System.Web.UI.HtmlControls.HtmlControl, ByVal initialheight As String, ByVal initialwidth As String, ByVal expandedheight As String, ByVal expandedwidth As String)Adds onmouseover and onmouseout JavaScript event handlers and CSS that causes a control's height and/or width to change when the mouse is moved on or off of the element.
  • ctrl - The WebControl or HtmlControl to add the JavaScript and CSS to
  • initialheight - The height, expressed as a CSS length value, that the control will have when not expanded
  • initialwidth - The width, expressed as a CSS length value, that the control will have when not expanded
  • expandedheight - The height, expressed as a CSS length value, that the control will have when expanded. If not specified, the CSS value 'auto' will be used
  • expandedwidth - The width, expressed as a CSS length value, that the control will have when expanded. If not specified, the CSS value 'auto' will be used
Source Code
Rollovers.vb:

Remarks
When using the expansion rollover methods, it is usually a good idea to make sure the page you use it on is still well designed, because depending on the expanded size of your target element in comparison to the initial size, the position and/or size of other elements could change by more than you would like, possibly confusing users or making the page less attractive. Keep in mind that all of these methods use the onmouseover and onmouseout JavaScript event handlers. Keep this in mind if you need these event handlers for any other reason.