Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2284
  • Last Modified:

.NET button font color change on mouseover

Is there any way to get a .NET (2003) web form asp button control to change font color on mouseover?

If not, I need a control that can do a rollover and still cause a submit and run a code behind click method on post-back.
0
nicholas_1969
Asked:
nicholas_1969
1 Solution
 
Ralf KlattPrincipal ConsultantCommented:
Hi,

I think this here is a very good example on how to build the desired function ... its about a calender control ... but generally very comprehensive ...

"Easily Adding Functionality to ASP.NET Server Controls - By Scott Mitchell"
http://aspnet.4guysfromrolla.com/articles/100103-1.aspx

Best regards, Raisor
0
 
CaptainRantflapsCommented:
Hi Raisor
Do the following :-

Create to style classes in your style sheet (or between Style tags on the html view of the page) one called btnOver - which is how you want the button to look when the mouse is over, the other called BtnOut

Now add you button to the page and set the cssclass property to BtnOut

then flip to the HTML view of the page from the page design view (bottom left of page)
find the button and add the following to line html
onmouseover="javascript:this.className='BtnOver'"  onmouseout="javascript:this.className='BtnOut'"

You whole line should now look a bit like

<asp:button id="CmdFinances" onmouseover="javascript:this.className='BtnOver'" style="Z-INDEX: 106; LEFT: 626px; POSITION: absolute; TOP: 11px" tabindex="101" onmouseout="javascript:this.className='BtnOut'" height="24px" text="Finances" cssclass="btn" width="112px" runat="server"></asp:button>

DONT WORRY ABOUT THE RED WAVY UNDERLINES - IT WILL STILL COMPLIE AND WORK.

No run your project and it should change as the mouse goes over.

Hope this helps

Simon.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now