English 中文(简体)
隐蔽的纽扣地控制 escaping含量。 如何制止?
原标题:Overridden button control escaping content. How to stop it?

I ve got a ASP. 我压倒一切地提供不同功能的纽顿控制网。 守则如下。 I m over the Render methods 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>");
    } 

当我检查网页上产生的来源时,我发现,在哪里,伙伴关系司。 Net已注入了它的点击手,它做到如下......

 <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>

......似乎放弃双重引用的产出,这意味着浏览器无法理解 j。

我如何使这一方法不能逃脱注射式伙伴关系。 网上客户点击手?

问题回答

我们ir。 我做了与你类似的工作,而且总是进行罚款。 为此:

public override void RenderControl(HtmlTextWriter writer)
{
    CssClass = "euva-button-decorated";
    //give the  a  a class
    writer.AddAttribute(HtmlTextWriterAttribute.Class, "euva-button");
    //open  a 
    writer.RenderBeginTag(HtmlTextWriterTag.A);
    //render the button
    base.RenderControl(writer);
    //close a
    writer.RenderEndTag();
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签