Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 5th, 2007, 10:18 AM
Authorized User
 
Join Date: Aug 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can display underline of text in Button when m

I add a Button in my webpage http://www.hothelpdesk.com, I hope the underline of text of the Button display when mouse move to the button, how can I do? thanks!

Note: the following code don't work!

<asp:Button runat="server"
  BorderColor="#ACA899" BorderStyle="Solid" BorderWidth="1px"
  CssClass="ForButtonInTable"
  SkinID="ButtonInTable">
</asp:Button>


.ForButtonInTable
{
    text-decoration: none;
}


.ForButtonInTable a:hover
{
    color: #666666;
    text-decoration: underline;
}


And more,when I hover mouse above a normal button, the backcolor of the button will change, but after I set BorderStyle and BorderWidth properties for the button, the backcolor of the button will not change again when I hover mouse above the button, why?




http://www.hothelpdesk.com/ - Web Based Helpdesk, Customer Service, Customer Support Software
__________________
Online Calculator - Online platform to create program with C# 4.0 and share with other people
Reply With Quote
  #2 (permalink)  
Old September 5th, 2007, 02:39 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii mycwcgr!!

you can do the thing in many ways
1>use javascript function and change class name.
2>or directly assign class name with mouseover and mouseout
Both the things are shown in the given example
3>you can add Attributes with style in ur C#,VB.net code file too

hope this will help you
<style type="text/css">
<!--
.mover{color:black;text-decoration:underline}
.mout{color:black;text-decoration:none}
-->
</style>
<input type=button id=btn value="test Button" onmouseover="this.className='mover'" onmouseout="chk('mout',this)">
<script>
function chk(cssClassName,obj)
{
obj.className=cssClassName

}
</script>

Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old September 5th, 2007, 06:09 PM
Authorized User
 
Join Date: Aug 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!
But I hope to do that on standard Button of ASP.NET server control!

I hope to set it as control Skin, so I can use the SkinId in any button.

I have many buttons to be setup, so I don't like to add Attributes with style to button one by one (BTW, could you give me a sample about adding Attributes with style).



http://www.hothelpdesk.com/ - Web Based Helpdesk, Customer Service, Customer Support Software
Reply With Quote
  #4 (permalink)  
Old September 5th, 2007, 06:19 PM
Authorized User
 
Join Date: Aug 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BTW, the following CSS don't work, could you write a css for me ,thanks!

<asp:Button runat="server"
  BorderColor="#ACA899" BorderStyle="Solid" BorderWidth="1px"
  CssClass="ForButtonInTable"
  SkinID="ButtonInTable">
</asp:Button>

.ForButtonInTable
{
    text-decoration: none;
}

.ForButtonInTable mouseover
{
    color: #666666;
    text-decoration: underline;
}


http://www.hothelpdesk.com/ - Web Based Helpdesk, Customer Service, Customer Support Software
Reply With Quote
  #5 (permalink)  
Old September 5th, 2007, 10:05 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by mycwcgr
 .ForButtonInTable mouseover
{
    color: #666666;
    text-decoration: underline;
}
This style selector is saying "apply this style to the element named 'mouseover' when it lives as a child of an element with the class 'ForButtonInTable' ".

I think you are missing the point that "hover" style changes are only natively supported by the A element pseudo class "A:hover". Regular buttons and such require something additional as other posters have pointed out. You can certainly define *how* you want the button to look using CSS, but ultimately you need to employ some script to change the CSS class to affect the change.

One way I have solved this type of problem when the a control's skin attributes aren't enough is by putting some code in my base page class that all pages inherit from (or similarly in a master page class) that performs a recursive search thru the page's control hierarchy to find the controls I wish to act upon. This way you could add the client-side javascript calls to the appropriate attributes of the control such as the "onMouseOver" call to the JS that appends/changes the control's class attribute.

Another way to solve this problem would be to use asp:linkbutton controls instead of buttons. Then you just have to style them to *look* like buttons, but they'll get the native hover support.

You said:
Quote:
quote:And more,when I hover mouse above a normal button, the backcolor of the button will change,
I suspect this is because the OS/browser you are using is doing this behavior. I have noticed this in Opera. As soon as you assign explicit styles to buttons the browser and OS respect those styles and don't change the button. Otherwise you get the default button appearance dictated by the environment you are in.

-Peter
Reply With Quote
  #6 (permalink)  
Old September 6th, 2007, 05:56 AM
Authorized User
 
Join Date: Aug 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!

The following code can work under IE 7.0, but don't work in IE 6.0, why?

It mean I can use Skin and CSS to display underline for a regular button when mouse hover it, right?


 <asp:Button runat="server"
   BackColor="#ECE9D8"
   BorderColor="#7F9DB9" BorderStyle="Solid" BorderWidth="1px"
   CssClass="ForButtonInTable"
   SkinID="ButtonInTable">
 </asp:Button>

.ForButtonInTable
{
    text-decoration: none;
    color: black;
}


.ForButtonInTable:hover
{
    text-decoration: underline;
    color: blue;
}



http://www.hothelpdesk.com/ - Web Based Helpdesk, Customer Service, Customer Support Software
Reply With Quote
  #7 (permalink)  
Old September 6th, 2007, 01:32 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I would imagine it works because I.E. 7 has support for the :hover pseudo class on more than just the A element.

-Peter
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need underline for did you mean ssvas BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 November 27th, 2008 03:05 AM
convert text to bold/italic/underline arunkhushi General .NET 0 August 21st, 2007 04:07 PM
How to remove the underline of the Image sfs00784 CSS Cascading Style Sheets 6 June 25th, 2005 11:10 PM
Display text onmouseover of radio button(ALT?) savoym HTML Code Clinic 1 September 16th, 2003 11:27 AM



All times are GMT -4. The time now is 11:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.