• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

ASP.NET menu and Safari. I know the fix, but user still needs to refresh page

Hi guys, I am seeing an odd issue. If you visit http://www.akaconsulting.com with Apple Safari or Chrome, you will see that the menus load all screwed up the first time. If you refresh the page however, they appear as they should. It shows ok after refresh because I applied the fix for AppleWebKit but user still has to refresh the page as mentioned above the first time.

For the life of me I have tried everything without luck. I have tried all the methods known in the Internet but nothing works. What am I missing here?

All suggestions appreciated.

Thanks!
protected void Page_Load(object sender, EventArgs e)
		{
            //Apple Web kit fix
            if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
            {
                //Request.Browser.Adapters.Clear();
                Page.Request.Browser.Adapters.Remove(typeof(Menu).AssemblyQualifiedName);
            }
}

Open in new window

0
Madestro
Asked:
Madestro
3 Solutions
 
masterpassCommented:
In the page directive <%@ Page ClientTarget="uplevel" ......%>   .... Safari works

or

You could also put it in the preint event
protected void Page_PreInit(object sender, System.EventArgs e)
{
    if (Strings.InStr(Request.ServerVariables("http_user_agent"), "Safari")) {
        Page.ClientTarget = "uplevel";
    }
}

Open in new window

0
 
LotokCommented:
It is not technically possible to programmatically create a one off page refresh. However there is a workaround, which I have been forced to use in the past.

If you have something databound. for example a DDL or Gridview. Delcare a temp datasource and then switch the control to use that, then back again to the correct datasource. This forces a page postback. It will do it only once and should go completely unnoticed.

It is a bit of a dirty work around, but only solution I ever found.
There is an example of what I mean below.
        If Not CType(ViewState("refreshed"), Boolean) = True Then
            ViewState("refreshed") = True
            'INSERT CODE HERE TO FORCE A POSTBACK. CHANGING A CONTROLS DATASOURCE TO SOMETHING ELSE AND
            'THEN BACK WILL DO IT
        End If

Open in new window

0
 
MadestroAuthor Commented:
I had been researching this for a while now and finally found a solution that works. I am posting it here so others can benefit from it:

1.In VS2008 Solution Explorer right click your application and add the “ASP.Net Folder” App_Browsers if you don’t already have it.
2.Add a New “Browser File” item to this special folder and call it something.browser
3.Delete all the default stuff VS put in this file and replace it with the code attached to this response.

It's the only thing that worked for me. You don't have to add any code to the application. You simply tell ASP.NET that the Apple Web Kit (which Safari and Chrome are based on) is an uplevel agent. Thank you for the replies anyways!
<browsers> 
  <browser refID=”safari1plus”> 
    <controlAdapters> 
      <adapter controlType=”System.Web.UI.WebControls.Menu” adapterType=”" /> 
    </controlAdapters> 
  </browser> 
</browsers>

Open in new window

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now