asp.net menu control not rending correctly in safari

后端 未结 9 975
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 17:56

The site I\'m working on is using a Databound asp:Menu control. When sending 1 menu item it renders HTML that is absolutely correct in Firefox (and IE), but really messed u

相关标签:
9条回答
  • 2020-12-31 18:57

    Adding ClientTarget="uplevel" to the page directive like so makes Safari work:

    <%@ Page ClientTarget="uplevel" ... %>
    
    0 讨论(0)
  • 2020-12-31 18:58

    Mayank Sharma found a solution that works with master pages, rather than editing individual pages. All pages that use the master page are fixed seamlessly. It's still a hack, but you do what you have to. Here's a barebones example master page code behind.

    using System;
    using System.Web.UI;
    
    /// <summary>
    /// Summary description for ExampleMasterPage
    /// </summary>
    public class ExampleMasterPage : MasterPage
    {    
        public ExampleMasterPage() { }
    
        protected override void AddedControl(Control control, int index)
        {
            if (Request.ServerVariables["http_user_agent"]
                .IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
            {
                this.Page.ClientTarget = "uplevel";
            }
            base.AddedControl(control, index);
        }
    }
    
    0 讨论(0)
  • 2020-12-31 19:02

    Works like magic!

        If Request.ServerVariables("http_user_agent").IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) <> -1 Or Request.UserAgent.Contains("AppleWebKit") Then
            Request.Browser.Adapters.Clear()
            Page.ClientTarget = "uplevel"
        End If
    
    0 讨论(0)
提交回复
热议问题