2

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.

Aleksandr Ivanov
  • 2,778
  • 5
  • 27
  • 35

1 Answers1

0

There is no need to write a custom control to do something that simple.

Look at how it is done here for input controls: http://attardi.org/labels/#info

This technique uses CSS positioning to superimpose a span. It might work for you.

Daniel Dyson
  • 13,192
  • 6
  • 42
  • 73