Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have html in Text attribute of asp Button

Tags:

asp.net

I'm trying to include an <i> for the Text attribute for an asp button but it's just rendering the html as text...

<asp:Button runat="server" ID="modify" ToolTip="Modify" CssClass="btn btn-mini" OnClick="modify_Onclick" Text='<i class="icon-edit"></i>' /> 

I've got to be over thinking this...

EDIT: I'm using the twitter bootstrap framework. That's why the <i> tag. Here's an example: http://twitter.github.com/bootstrap/base-css.html#icons

like image 236
bflemi3 Avatar asked Jul 13 '12 21:07

bflemi3


People also ask

How do I make a button do something in HTML?

The <button> element is used to create an HTML button. Any text appearing between the opening and closing tags will appear as text on the button. No action takes place by default when a button is clicked. Actions must be added to buttons using JavaScript or by associating the button with a form.

How do I make a button clickable in HTML?

The <button> tag defines a clickable button. Inside a <button> element you can put text (and tags like <i> , <b> , <strong> , <br> , <img> , etc.). That is not possible with a button created with the <input> element!

What is ASP button?

asp:Button is an asp.net server control which fire an event on the server side. <input id="Submit1" type="submit" is a client side button of type submit, but it can act as a server side button as well by adding. runat="server" and onserverclick="eventname"


2 Answers

You can use <asp:LinkButton. Bootstrap renders anchor tags (asp:LinkButton) like input type submit buttons (asp:Button).

<asp:LinkButton runat="server" ID="modify" ToolTip="Modify" CssClass="btn btn-mini" OnClick="modify_Onclick" Text='<i class="icon-edit"></i>' /> 
like image 85
Cem Avatar answered Sep 29 '22 18:09

Cem


What I ended up doing was going with an html button, runat=server and putting the <i> inside of that.

<button runat="server" id="modify" class="btn btn-mini" title="Modify" onserverclick="modify_Onclick">     <i class="icon-edit"></i> </button> 
like image 23
bflemi3 Avatar answered Sep 29 '22 19:09

bflemi3