Whidbey: Adaptive Rendering : Sometimes you dont want it...

Tags: Tech Geek

As some of you may know V2 of .NET will actually allow the Web Controls to adaptively render based on the browser capabilities on the client.  You hit with IE, it will render some IE stuff, you hit with a WAP browser, it will render only WAP stuff.  Very very handy when you want to support all these platforms.  Heck you can even choose specific master pages to target specific devices. 

Well, what about when you DONT want to do the adaptive rendering?  You see, when you want too use this cool feature the old <FORM runat="server"> tag MUST be present.  For most situations this is good and acceptable, but for many situations you dont want the form tag to be emitted.  Say you wish to pump out XML directly to the client, including changing the content type on the response...etc... We've all did this I'm sure.  You dont want the silly <FORM> tags to be emitted, thus messing up the actual content.  Oh yeah, and you DO want to hit this with a wireless device.  Lets say your emitting binary data (wbmp) or whatever for the wireless device right within an ASPX page... 

The solution (my wild guess, that worked), in order to handle this situation is to simply stop the adpative rendering from working its magic.  To do this, do something like:

<script runat="server" language="c#">

void Page_Load (object sender, System.EventArgs e) {

Page.Visible = false;

Response.ContentType = "text/xml";

Response.Write ("<SOME_XML_STUFF_HERE />");

}

</SCRIPT>

Notice the:

Page.Visible = false;

Now you can hit the page, with a normal browser (IE), or an alternative browser (WAP) and you will get the same results, no adpative rendering error.

No Comments