Dailycode.info

Short solution for short problems

Looking for nice Style for your web part buttons for WSS?

I made some webparts that are using htmlbuttons to perform some actions. At first I kept the ugly default button style. But when I found some spare time I start looking for some nice CSS classes to put on my buttons. I chose to use style of SharePoint itself, making sure the buttons will change their looks when I change the theme.

Here is the result of which I'm very pleased.

Before:

After:

The Yes button is the hoover style, the No button is the normal style. The colors used are the same as the Tab on top. Here's the code from my webpart:

_myNoReview = new HtmlButton();
_myNoReview.InnerText = "Yes";
_myNoReview.Attributes.Add("class", "ms-SPButton ms-WPAddButton");
_myNoReview.Attributes.Add("onmouseover", "this.className='ms-SPButton 
ms-WPAddButton ms-WPAddButtonHover';");
_myNoReview.Attributes.Add("onmouseout", "this.className='ms-SPButton ms-WPAddButton';");
 
_myNoReview.ServerClick += new EventHandler(_mybutton_click);
Controls.Add(_myNoReview);