Link to home
Start Free TrialLog in
Avatar of santaspores1
santaspores1Flag for United States of America

asked on

asp.net Gradient Button

Hello,
I thought this would be a simple find, but apparently not...

What I want is a simple method for creating buttons that have a two-color gradient as their background.
Here are the technologies I am using:
Visual Studio 2008 as IDE
ASP.net 3.0
Visual Basic with code-behind
Themes with CSS and skins

What I would like is to create a .net button (not an html button if it can be avoided) that has a two-color gradient as the background.  Preferably the background gradient can be created automatically requiring only my color choices and not requiring me to create a gradient.png if it can be avoided.  I would also like to keep thing simple if possible.  I would prefer not to have to use a button-generator package of any kind, but if I have to, it must be freeware (I really want to avoid using other peoples packages though).  Additionally, if it isn't any more difficult I would also like to be able to specify a graphic to be placed over the button background as well.  So I would have an asp button with a gradient background, a small image and some text.  And finally, in a perfect world, it would have browser side hover actions (though this isn't very important).

Is there anyone that can walk me through this?  
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puru1981
puru1981

you can create gradient buttons in silverlight. but if you want to do this without silverlight then you need to have image created for those buttons.
Avatar of santaspores1

ASKER

YZlat:

in my aspx:
<asp:Button ID="testbutton" runat="server" Text="MyButton" />

in the page_load sub of my .vb file:
testbutton.Style.Add("filter:progid", "DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2',startColorstr='#FFFFFF',gradientType='0');")

button had no gradient - just shows as the defualt css styled button.

Do I need to inherit anything besides System.Web.UI.Page?  The code didn't cause any build errors.


puru1981: I don't want to use silverlight.
YZlat: oh, I see.  This works in IE but not firefox.  Any cross-browser solution?
Happy to award you the points though - I didn't specify cross-browser compatibility.
Thanks!  If you know of a cross-browser solutions I would love to hear that as well.

it should work in FireFox 3.6 or less
Thanks again YZ - I appreciate it.