HOW TO control ASP.NET's Adaptive Rendering behavior

ASP.NET server controls detect browser type automatically & render differently in modern non-IE browsers like Opera & Firefox. Sometimes this may be undesirable. For instance, a textbox server control with the property AutoCompleteType="Disabled" like so:

<asp:TextBox id="txtSecret" runat="server" AutoCompleteType="Disabled" >


</asp:TextBox>



is rendered as this in IE 6 -

<input name="txtSecret" type="text" autocomplete="off" id="txtSecret" />



whereas it will adaptively render without the autocomplete attribute in Firefox 2.0 like this -

<input name="txtSecret" type="text" id="txtSecret" />



Although the autocomplete attribute is a non-standard HTML property it is supported in Firefox. So how do we make this attribute show up in Firefox?

By setting the @ Page directive's ClientTarget property to "uplevel", we can force the page to render in Firefox (or any other non-IE browser) as it does in IE 6.

<%@ Page Language="C#" ClientTarget="uplevel" %>




You may have to verify that your other tags also render as desired in non-IE browsers.

Related reading:
ASP.NET Web Server Controls and Browser Capabilities
Architectural Overview of Adaptive Control Behavior
Dissecting Adaptive Rendering
A Look at ASP.NET's Adaptive Rendering

Comments

  1. Well i tried it,
    but its not working for me in firefox...

    ReplyDelete
  2. Hi,
    i tried ur method.but it doesnt seem to work for me in firefox.

    Any idea why?

    ReplyDelete
  3. What about:

    TextBox ID="txtAnswer" runat="server" width="100%" AutoComplete="OFF"

    ReplyDelete

Post a Comment

Popular posts from this blog

GitHub Copilot Q&A - 1

Maven Crash Course - Learn Power Query, Power Pivot & DAX in 15 Minutes

Datawrapper Makes Data Beautiful & Insightful