【问题标题】:Escape Key Issues with Update Panel使用更新面板逃避关键问题
【发布时间】:2014-01-03 05:43:20
【问题描述】:

在包含更新面板且内部包含任何控件的页面上按两次 ESC 键时,例如文本框或列表框我得到 System.ArgumentException: Invalid postback or callback argument。我已经检查了其余浏览器的工作正常,但在 Internet Explorer 8 中它产生了上述问题。

我找到的可能解决方案是在页面级别或 webconfig 或 禁用转义键 上设置 EnableEventValidation="false"。我不想使用 2 个以前的解决方案,因为我的网站安全性会受到影响,而且我不希望我的转义键被禁用。

任何建议/想法表示赞赏。

代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"
        EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanelHeader" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div id="Search">
                <table style="empty-cells: hide;" width="100%" cellpadding="0" cellspacing="0" class="controlsTable">
                    <tr>
                        <td class="td4Caption">
                            Some Text
                        </td>
                        <td class="tdpadding">
                            <asp:TextBox ID="txtbox" ClientIDMode="Static" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:ImageButton SkinID="Export" AlternateText="Generate Report" ToolTip="Generate Report"
                                ID="ibtnGenerateReport" ValidationGroup="Generate" runat="server" OnClick="ibtnGenerateReport_Click" />
                        </td>
                    </tr>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>

【问题讨论】:

  • 你可以考虑在客户端处理esc键吗?
  • @NoviceProgrammer 是的.. 我需要退出键来关闭模式弹出窗口。所以不能禁用转义键。但重要的一点是它在 IE8 中的创建问题只存在于所有运行良好的浏览器中:(
  • 你能发布你的代码吗?
  • @DaveMroz 我添加了一个代码供参考。
  • 我建议您尝试在页面加载事件中使用try{ ... code here } catch(Exception){ ... any code handling } 处理它,如果这种情况仅发生在 IE8 中,那么每次它会回发您可以控制发生的情况

标签: c# asp.net internet-explorer-8 asp.net-4.0


【解决方案1】:

•您可以尝试的另一件事是:EnablePartialRendering="false" to asp:ScriptManager

使用“edge”确保您的网站以适当的兼容性呈现:

如果以上都不起作用,请尝试像这样控制异常处理程序:

http://encosia.com/how-to-improve-aspnet-ajax-error-handling/

猜你喜欢
  • 2011-06-05
  • 2011-10-10
  • 1970-01-01
  • 2020-11-25
  • 2011-09-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多