【问题标题】:Update panel in IE 10IE 10 中的更新面板
【发布时间】:2013-08-28 06:08:37
【问题描述】:

我在 Asp.net 中创建了一个示例程序,它会在单击按钮时更新时间。此时间显示在标签中。按钮和标签都在更新面板中,比如 upd1。 以下是aspx代码

<script type="text/javascript" >
function fnhn() {

    __doPostBack("upd1","");
    return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
     <asp:ScriptManager id="ScriptManager1" runat="server" EnablePageMethods ="true"  >    </asp:ScriptManager> 
<div>
 <asp:UpdatePanel ID="upd1" runat ="server" ><ContentTemplate > 
 <asp:label runat="server" id="lbl_c" ></asp:label>
  <asp:button runat="server" id="btn_b" Text="Click" />
 </ContentTemplate>
 </asp:updatepanel>
</div>
</form>
</body>

以下是源代码。

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    lbl_c.Text = Date.Now.ToString
End Sub
End Class

现在我面临的问题如下。我可以在按钮单击时更新这次,而无需在 IE 10 以外的任何浏览器中进行任何回发。在 IE10 中,我的整个页面都会刷新。我显然不想发生。请帮帮我。

在一个帖子中我也通过以下方式了解了升级IE10的用户代理。

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    If Request.UserAgent.ToLower.ToString.Contains("msie 10.0") Then
        Page.ClientTarget = "uplevel"
    End If
End Sub

这并没有帮助我摆脱这个问题。 任何意见建议和解决方案都很有价值。

【问题讨论】:

  • If Request.UserAgent.ToLower.ToString.Contains("msie 10.0") .... 警告:在使用用户代理字符串识别浏览器时要非常谨慎。将它用于任何重要的事情被认为是不好的做法,因为 UA 字符串可能会欺骗您,因为它在用户的控制之下。此外,IE11 UA 字符串完全不同,因此当您的用户升级时,您的检查将不起作用。

标签: javascript asp.net ajax internet-explorer updatepanel


【解决方案1】:

你能检查一下你的 IE10 是否允许 cookie 吗?如果您在某个时候禁用了 cookie,则会话将无法工作(如果基于 cookie),因此 AJAX 将导致完整的回发。

【讨论】:

    【解决方案2】:

    您是否尝试过添加 EnablePartialRendering?这应该是默认值,但可能会在其他地方被覆盖。

    <asp:ScriptManager id="ScriptManager1" runat="server" 
                EnablePageMethods="true" EnablePartialRendering="true" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-28
      • 1970-01-01
      • 1970-01-01
      • 2022-10-04
      • 2011-04-02
      相关资源
      最近更新 更多