Create Rollover Graphics in ASPX Pages

Create Rollover Graphics in ASPX Pages

Although this tip creates onmouseover and onmouseout attributes in the IMG tag within the A tag when rendered to the browser, it could be used to set any attributes.

Create a Hyperlink control on the .aspx page (with an ID of ‘lnkImage’ in this example). In the codebehind, create a new image, set it’s attributes and add it to the controls collection of the hyperlink (substitute you own images for icon.gif and icon_hot.gif):

Private Sub Page_Load ...    Dim IMG as new WebControls.Image    IMG.ImageUrl = "Images/icon.gif"    IMG.Attributes.Add("onmouseover", "this.src='Images/image_hot.gif';")    IMG.Attributes.Add("onmouseout", "this.src='Images/image.gif';")    IMG.Controls.Add(IMG)End Sub
See also  5 Strategies for Supercharging Your CRM

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist