LinkButton child controls render

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-25T08:19:38Z Indexed on 2010/05/25 8:31 UTC
Read the original article Hit count: 229

Filed under:
|
|

Hi.

I want to have a LinkButton that adds 'span' tag around the text.

 protected override void Render(HtmlTextWriter writer)
    {

        Text = String.Concat("<span>", Text, "</span>");
        base.Render(writer);
    }

It's works perfectly, but only if I add text like this:

<cc:TestLinkButton ID="TestLinkButton" runat="server" Text="SomeText">  
</cc:TestLinkButton>

If I want to add some image I will write something like this:

<cc:TestLinkButton ID="LinkButton1" runat="server">
        <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/icon_holiday.png"                 BorderWidth="0" />
        SomeText
</cc:TestLinkButton>

In this case Text property will be empty, because actualy "SomeText" is child control property.

So question is is how to add tag around child controls.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about linkbutton