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

MadestroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.