quest_for_truth_gal
New Member
What is the easiest way using VB and asp.net web controls to make button mouseovers? Also, can this be done without using images?<BR><BR>This is what I've tried so far but I get a runtime error when I actually mouse over the button..<BR><BR><%@ Page Language="VB" %><BR><%@ Import Namespace="System.Drawing" %><BR><BR><script runat="server"><BR>Sub btnSubmit_MouseOver(obj as Object, e as EventArgs)<BR> Dim MouseOverStyle As New Style<BR> MouseOverStyle.BackColor = Color.Red<BR> MouseOverStyle.ForeColor = Color.Black <BR> MouseOverStyle.BorderStyle = BorderStyle.Dashed<BR> btnSubmit.ApplyStyle(MouseOverStyle)<BR>End Sub<BR></script><BR><BR><html><body><BR><form runat="server"><BR><asp:button <BR> id="btnSubmit"<BR> AutoPostBack="true"<BR> text="None"<BR> OnMouseOver="btnSubmit_MouseOver"<BR> OnClick="Submit"<BR> BackColor="beige"<BR> ForeColor="olive"<BR> BorderWidth="3"<BR> BorderStyle="None"<BR> ToolTip="Click Me!"<BR> runat="server"<BR>/><BR></form><BR></body><BR></html>Just add this when the page loads<BR><BR>btnSubmit.Attributes.Add("onmouseover","this.style.backgroundColor='red';this.style.color= 'black';this.borderStyle='dashed';this.style.borde rWidth='2px'")<BR>btnSubmit.Attributes.Add("onmouseout","this.style.backgroundColor='';this.style.color=''; this.borderStyle='solid'; this.style.borderWidth=''")<BR><BR>mattwow, thanks so much!! =)You can also just add the properties to your button declaration at design time. Below is your code with the properties added.<BR><BR><asp:button <BR> id="btnSubmit" <BR> AutoPostBack="true" <BR> text="None" <BR>OnMouseOver="this.style.backgroundColor='red';this.style.color= 'black'"<BR>OnMouseOut="this.style.backgroundColor='blue';this.style.color ='white'"<BR> BackColor="beige" <BR> ForeColor="olive" <BR> BorderWidth="3" <BR> BorderStyle="None" <BR> ToolTip="Click Me!" <BR> runat="server" <BR>/>