Tucker County Fair web site!

   I've been on the Tucker County Fair board for the 2008-2009 year. I got the board to agree to let me register a domain name and setup a web site for them. I think it's comming along pretty good so far, but man the issues with CSS and browser compatibiilty - it can make you nuts!

   Anyway, I've gotten the web site structure setup and it seems to be working good across common browsers as well as Mac's.

   There was a special fix I had to deal with for Mac's running Safari and Opera that had to do with the ASP.NET menu control. I found a couple of fixes that involved creating a new class that inherits System.Web.UI.Page (we'll call this class "PageBase") which has an event handler for the Page_PreInit event to set Page.ClientTarget = "uplevel". However, this method requires setting all the Pages to inherit the new PageBase class instead of the System.Web.UI.Page class. This method also has to be used when using MasterPages, as MasterPages don't support the Page_PreInit event. That's why you have to do it in the new PageBase class. This solution requires a lot of work in terms of creating the new PageBase class and having to make sure that every page you create from then on uses the new PageBase class instead of System.Web.UI.Page. If you forget to change it (which is easy as Visual Studio uses System.Web.UI.Page by defaul when you add a new web page), the page won't display properly.

  Anyway, I ended up finding a site that had a solution based on the use of the global.asax file. The site was: here almost at the bottom. It was a post by "O". The first part of this discussion page talks about the new PageBase class method, but "O"'s post pulled a couple of the solutions together making it a simple matter of adding the global.asax file and adding the following code: (translated to c# by me)

void Application_BeginRequest(object sender, EventArgs e)
{
   try
   {
      if (Request.UserAgent != null && Request.UserAgent.IndexOf("AppleWebKit", StringComparison.CurrentCultureIgnoreCase) > -1)
      {
         Request.Browser.Adapters.Clear();
      }
   }

   catch (Exception ex)
   {
      throw(ex);
   }
}
 
   This is MUCH simpler! Simply create one file, copy this code in, and the problem is fixed without the PageBase class and having to modify all of the pages to inherit PageBase (and having to remember to make all new pages inherit PageBase as well). Thanks "O"!

   Hope this helps!
 
   By the way, the site I'm working on is here: Tucker County Fair. Any suggestions or comments are welcome.

Comments

Popular posts from this blog

IntelliSense Not Working in Microsoft SQL Server Management Studio/Express 2008?