I have an issue when i try to render the linkbutton with image and text it isn't rendered correctly. I render it from a servercontrol in method OnLoad. And I do not understand why, maybe someone knows the problem.
Here is the code:
StringBuilder builder = new StringBuilder();
builder.Append("<div>");
builder.AppendFormat("<asp:LinkButton runat='server' id='someid_{0}' OnClientClick='{0}_perfrom();'>", this.ClientID);
builder.AppendFormat("<span><span><img style='border:0' id='SomePic_{0}' src='/_layouts/images/mypict.png' />", this.ClientID);
builder.Append("Text</span></span></asp:LinkButton>");
builder.Append("</div>");
this.Controls.add(new LiteralControl(builder.ToString()));
The result is:
<div>
<asp:linkbutton id="" runat="server" /> //here by some reason the tag is closed
<span>
<span>
<img ....>
Text
</asp:linkbutton /> //and also here
</div>
Any idea, why such a strnge behaviour?