我固定的Safari浏览器/ ASP:采用AddedControl在方法菜单的问题。为什么这项工作? [英] I fixed the safari/asp:menu issue using addedcontrol method. Why does this work?
问题描述
我用下面的code在母版的CS文件来修复Safari和ASP的的渲染问题:菜单控制。我为什么它实际上解决了这个问题好奇。这里是code:
I used the following code in the cs file of the masterpage to fix the rendering issue of the safari and the asp:menu control. I was curious on why it actually fixes the problem. Here is the code:
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);
}
推荐答案
的问题是,ASP.NET错误识别Safari浏览器作为下层的浏览器(例如古)。您的修补程序迫使它认识到它作为一个更现代的浏览器,并能够处理一些菜单的JavaScript的。
The problem is that ASP.NET erroneously recognizes Safari as a "downlevel" browser (e.g. ancient). Your fix is forcing it to recognize it as a more modern browser that is capable of handling some of the menu's javascript.
这也将通过一些其他技术,如覆盖Page_ preINIT或添加适当配置safari.browser为App_Browsers文件工作。
This will also work via a bunch of other techniques such as overriding Page_PreInit or adding a properly configured safari.browser to App_Browsers.
这篇关于我固定的Safari浏览器/ ASP:采用AddedControl在方法菜单的问题。为什么这项工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!