asp.net menu control not rending correctly in safari

后端 未结 9 984
没有蜡笔的小新
没有蜡笔的小新 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: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 description for ExampleMasterPage
    /// 
    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);
        }
    }
    

提交回复
热议问题