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.

+1


source to share


4 answers


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.

0


source


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.

+1


source


I don't think the output of the LinkButton control could be more CSS friendly. This is a pure HTML anchor.

0


source


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.

0


source







All Articles