Using Inner HTML with an ASP:Button?

How can I convert

<button type="submit" class="blue">
<span>Login</span>
</button>

Into an asp button?

<asp:Button ID="Button1" runat="server" Text="Button" />

<asp:LinkButton ID="LinkButton1" runat="server" CssClass="blue"><span>Login</span></asp:LinkButton>

I just simply cannot find a way to do it. Sorry its a crappy question, but it's throwing me for a loop, might just need to sleep on it.

Answers


If you really need rich formatting either you use a css class and define all styling in the css side or you can use an html anchor

I am not aware of another way to compose the inner html of a button or linkbutton like you are trying to do.


I agree with Davide that CSS is the best solution but if you have some styling requirement which requires multiple tags then LinkButton is your best bet. You can apply all the styles you would to have put on 'button' tag on to the 'a' tag.

    <asp:LinkButton ID="submit" runat="server" OnClick="Submit_Click" CssClass="block-button">
        <span runat="server" ID="submitText" ClientIDMode="Static" class="block-button-text">Submit</span><span class="block-button-arrow">&nbsp;</span>
    </asp:LinkButton>

If you really must have a button tag then the only way is to create a custom control that implements all the functionality of asp:button

See here for a solution by prabhakarbn http://forums.asp.net/t/1496938.aspx/1


Need Your Help

Laravel SQL Query difficult

php sql laravel-4

I can't "translate" the SQL Query below to Laravel, how I can make this?

Problems with NSXMLParser

ios objective-c ios7 xml-parsing nsxmlparser

I am using NSXMLParser to parse an XML file so that I can display data from an RSS feed in table view. However, title data is correctly parsed and passed to the appropriate array, but upon passing ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.