ASP.NET LinkButton CSS Adapter
Does anyone know of a CSS adapter for LinkButton control for ASP.Net 2?
Update:
We are trying to use CSS buttons. We use this approach: http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html To do this, we need to render the tags that the link button does not do.
Possible solution using an adapter
We've created an adapter for the linkbutton. Then we changed the RenderContents as follows:
protected override void Render(HtmlTextWriter writer) {
LinkButton linkButton = this.Control;
linkButton.Text = String.Concat("<span>", linkButton.Text, "</span>");
base.Render(writer);
}
This seems to work and requires minimal effort.
Possible solution using an adapter
We've created an adapter for the linkbutton. Then we changed the RenderContents as follows:
protected override void Render(HtmlTextWriter writer) {
LinkButton linkButton = this.Control;
linkButton.Text = String.Concat("<span>", linkButton.Text, "</span>");
base.Render(writer);
}
This seems to work and requires minimal effort.
Create a Web Control that inherits from LinkButton
and only overrides the method RenderContents
.
It's pretty straightforward and you don't need to duplicate any code or re-execute any functions. It is of course helpful to use the .NET Framework source to take a look at the original implementation.
I don't think the output of the LinkButton control could be more CSS friendly. This is a pure HTML anchor.
You can easily do this with a custom control or a custom render control
<a...><span>[text]</span></a>
OR - you can use jQuery to find all anchors (possibly with a given class) and insert the range for you.