Overridden button control escaping content. How to stop it?

Posted by RemotecUk on Stack Overflow See other posts from Stack Overflow or by RemotecUk
Published on 2010-04-16T09:15:20Z Indexed on 2010/04/16 9:23 UTC
Read the original article Hit count: 378

Filed under:
|

Hi,

I've got an ASP.Net button control that I have overridden to provide different functionality. the code looks as follows.. I'm overriding the Render method to surround the control with an <a>...

    /// <summary>
    /// Render Method
    /// </summary>
    /// <param name="writer"></param>
    protected override void Render(HtmlTextWriter writer)
    {
        base.CssClass = "euva-button-decorated";
        writer.Write("<a class=\"euva-button\">");
        base.Render(writer);
        writer.Write("</a>");
    } 

When I check the generated source on the page, I find that where ASP.Net has injected its click handler it does the following...

 <a class="euva-button"><input type="submit" name="TestButton" value="Test Button" onclick="clickOnce(this);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;TestButton&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="TestButton" class="euva-button-decorated" /></a>

... it seems to be escaping the output for the double quotes which means that the browser cannot understand the javascript.

How do I make the render method not escape the injected ASP.Net client click handler ??

Note I also have my own client click handler which is declared declaratively in the page mark-up.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about button