How to set css style to asp.net button?
I have a asp:Button, I used css styles with cssClass property in asp:Button
, but those styles are not working. When I use asp:LinkButton
those styles are working well.I don't want any themes or skins for styles.
This is my asp page:
<asp:Button CssClass="smallButton" Text="Sign In" runat="server" ID="submit"></asp:Button>
This is my CSS:
.smallButton
{
//styles
}
When I change asp:Button to asp:LinkButton
<asp:LinkButton Text="Sign In" runat="server" ID="submit" CssClass="smallButton"></asp:LinkButton>
or
<span class="smallButton"><asp:LinkButton Text="Sign In" runat="server" ID="submit"></asp:LinkButton></span>
styles are working well. Only problem with the asp:Button control
You can assign a class
to your ASP.NET
Button and then apply the desired style to it.
<asp:Button class="mybtn" Text="Button" runat="server"></asp:Button>
CSS:
.mybtn
{
border:1px solid Red;
//some more styles
}
I Found the coding...
input[type="submit"]
{
//css coding
}
input[type="submit"]:Hover
{
//css coding
}
This is the solution for my issue..... Thanks everyone for the valuable answers.......
You can use CssClass
attribute and pass a value as a css class name
<asp:Button CssClass="button" Text="Submit" runat="server"></asp:Button>`
.button
{
//write more styles
}
nobody wants to go to the clutter of using a class, try this:
<asp:button Style="margin:0px" runat="server" />
Intellisense won't suggest it but it will get the job done without throwing errors, warnings, or messages. Don't forget the capital S in Style