Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap on asp.net button

Is there a way that i can bind bootstrap onto asp controls?

Bootstrap button :

       <button type="button" class="btn btn-default btn-lg">
  <span class="glyphicon glyphicon-cog"></span></button>

Asp.net button:

    <asp:Button ID="Button1" runat="server" Text="Button" class="btn btn-default btn-lg"/>//How i add the span class? or is there a work around?

If this is not possible, is there a way that the html button can trigger of .net eventfunction?

protected void Button1_Click(object sender, EventArgs e)
    {
        //Do something.
    }

I've tried adding onclick ="Button1_Click" on the html, it does not work.

like image 465
Joshua Tan Avatar asked Oct 01 '14 01:10

Joshua Tan


People also ask

Can Bootstrap used with ASP NET?

Since Bootstrap is all HTML, CSS and JavaScript, all open standards, you can use it with any framework including ASP.NET MVC. When you start a new MVC project, Bootstrap will be present, meaning you'll find Bootstrap. css and Bootstrap. js in your project.

What is bootstrap in ASP?

Bootstrap is a popular web framework which is used to create responsive web application that can run even on the mobile device. It provides HTML, CSS and JavaScript libraries to build applications. ASP.NET MVC, by default supports Bootstrap and use it's libraries to create frontend of the application.


1 Answers

You can use the <asp:LinkButton> to add your icon to the button. e.g.

<asp:LinkButton ID="CogLinkButton" CssClass="btn btn-default btn-lg" runat="server" OnClick="CogLinkButton_Click"><span class="glyphicon glyphicon-cog"></span></asp:LinkButton>
like image 54
luke2012 Avatar answered Sep 25 '22 23:09

luke2012