ASP.NET LinkButton: children disappears after postback

I have a LinkButton with image and label inside it or tags i and span as in the following picture.example_linkbutton

The code in the page is:

<asp:LinkButton ID="LinkButton1" runat="server">
    <i class="glyphicon glyphicon-plus"></i>
    <span class="js-add-button" runat="server" id="Span1">Add New</span>
</asp:LinkButton>

After a postback everything inside the LinkButton disappeared. I’ve spent two days to understand why and the solution is very easy.

<asp:LinkButton ID="LinkButton1" runat="server">
    <i class="glyphicon glyphicon-plus" runat="server"></i>
    <span class="js-add-button" runat="server" id="Span1">Add New</span>
</asp:LinkButton>

The tag i doesn’t have runat="server" and for that you lost all content inside the LinkButton.

Happy coding!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.