Posts Tagged ‘ASP.NET’

Those who have been working in ASP.NET MVC are already aware of the ASP.NET Routing feature introduced with .NET 3.5 SP1.But I have seen many who has developed a perception that ASP.NET Routing is something that can be used with only ASP.NET MVC.This is not the case.ASP.NET Routing comes under a separate namespace (System.Web.Routing) and assembly (System.Web.Routing.dll).This can be used with WebForms applications as well.But this required some custom coding to develop your RouteHandler as shown in the post below:

http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx

In ASP.NET 4.0, added capabilities are provided to make routing fully complete in order to work with WebForms.This is what I will be discussing in this post today.I will use simple webpage with 2 hyperlinks to demonstrate this feature.

(more…)

Advertisements

ASP.NET AJAX & XHTML Conformance

Posted: July 25, 2008 in AJAX, ASP.NET
Tags: ,

For the past few days I faced strange problems while implementing ASP.NET AJAX UpdatePanel in an application running on framework 3.5.The same page was using ASP.NET AjAX ScriptService perfectly fine.On examining the HTML source of the page I found that the markup and <script> tags required for proper functioning of ASP.NET Ajax was not emitted at all.This application was actually migrated from 1.1 to 3.5 using the application migration wizard.While migrating the application the wizard adds the following lines of code web.config

<system.web>
        
<xhtmlConformance mode=”Legacy” />
</
system.web>
This was the main culprit.The markup emitted by framework 1.1 is not XHTML compliant.So to maintain compatibility the xhtnmlConformance mode is set to Legacy.The other two values are “Strict” and “Transitional”.ASP.NET AJAX UpdatePanel does not work properly with XHTML Conformance mode legacy.Changing the mode to Strict or Transitional was causing distortion and javascript related issues.In legacy mode the id of the server controls is rendered as UserControlID:ControlID whereas in mode Strict or Transitional it is rendered as UserControlID$ControlID.

So we evaluated the option of setting XHTML conformance mode to Legacy for the existing folders and Transitional or Strict for the folder containing new web pages using the <location> tag in Web.config.This also did not workout as the application uses FrontController pattern for page to page and menu navigation.So all the requests are first send to the frontconroller and then to individual pages using Server.Transfer.As the requests are not directly routed to pages in the new folder XHTML conformance mode was not changed.

So we added another aspx pointing to the same httpHandler and manipulated the location tag as follows:

<configuration>
   <system.web>
      <httpHandlers>
         <add verb="*"
              path="OldFrontController.aspx"
              type="MyHandler.New,MyHandler"/>
         <add verb="*"
              path="NewFrontController.aspx"
              type="MyHandler.New,MyHandler"/>
     </httpHandlers>
   <system.web>
<location path=".">
	<xhtmlConformance mode="Legacy"/>

</location>
<location path="NewFrontController.aspx">
	<xhtmlConformance mode="Transitional"/>
</location>
</configuration>

This led to proper functioning of the UpdatePanel.