Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 716
Sujanth Avatar asked Aug 29 '12 12:08

Sujanth


People also ask

How do I change the style of a button in HTML?

Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".

What is CssClass in asp net?

ASP.Net CssClass is an abstract wrapper around the css "class" specifier. Essentially, for most intents and purposes, they are the same thing. When you set the CssClass property to some string like "someclass", the html that the WebControl will render will be class = "someclass" .

What is a button in CSS?

TL;DR – CSS buttons refer to styled HTML buttons that developers customize to match their website designs. You can manipulate the colors, text sizes, padding, and even change styling properties when buttons enter different states.

What is button in asp net c#?

ASP.NET provides three types of button control: Button : It displays text within a rectangular area. Link Button : It displays text that looks like a hyperlink. Image Button : It displays an image.


2 Answers

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
}
like image 62
Priyank Patel Avatar answered Oct 14 '22 08:10

Priyank Patel


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.......

like image 44
Sujanth Avatar answered Oct 14 '22 06:10

Sujanth