LinkButton child controls render
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" />
SomeTe开发者_Go百科xt
</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.
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.
精彩评论