ControlExtensions Module
Description
The ControlExtensions Module contains several Extension Methods that can be used with all WebControls and/or HtmlControls to simplify several common tasks.
Example
WebControl
Me.pnlWebControl1.AddRolloverBackgroundColor(Drawing.Color.Blue)
Me.imgWebControl1.AddRolloverBackgroundColor(Drawing.Color.Orange)
Me.pnlWebControl2.AddRolloverBackgroundColor(Drawing.Color.Blue, Drawing.Color.Red)
Me.imgWebControl2.AddRolloverBackgroundColor(Drawing.Color.Orange, Drawing.Color.Magenta)
HtmlControl
Me.divHtmlControl1.AddRolloverBackgroundColor(Drawing.Color.Blue)
Me.imgHtmlControl1.AddRolloverBackgroundColor(Drawing.Color.Orange)
Me.divHtmlControl2.AddRolloverBackgroundColor(Drawing.Color.Blue, Drawing.Color.Red)
Me.imgHtmlControl2.AddRolloverBackgroundColor(Drawing.Color.Orange, Drawing.Color.Magenta)
Properties & Methods
AddRolloverBackgroundColor(ByVal rollover As System.Drawing.Color)This Extension Method can be used with all WebControls and HtmlControls to add a rollover which changes the background color. The rollover color will be the color specified, and the rollout color will be the CSS value 'transparent'.
  • rollover - The background color used when the user rolls over the WebControl or HtmlControl
AddRolloverBackgroundColor(ByVal rollover As System.Drawing.Color, ByVal initial As System.Drawing.Color)This Extension Method can be used with all WebControls and HtmlControls to add a rollover which changes the background color. The rollover and rollout colors will be the colors specified in the rollover and initial parameters.
  • rollover - The background color used when the user rolls over the WebControl or HtmlControl
  • initial - The color used as the initial background color and the background color when the user rolls out of the WebControl or HtmlControl
Source Code
ControlExtensions.vb:

Remarks
When using the AddRolloverBackgroundColor Extension Methods with an ImageButton, be sure to keep in mind that the rollover will not work when Enabled="False".