0

因此,我在 ASP.NET WebForm 应用程序中有一个 jQuery 对话框,我从该对话框中将所有包含的控件的内容发布到另一个页面。问题是 FileUpload 控件。当 EnablEventValidation 设置为 true(我认为默认情况下)时,我收到此错误...

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

...如果我设置EnableEventValidation='false'FileUpload控件中设置的图像被发布,但我所有其他发布的值都返回为空。所以我想我要么需要禁用控件,要么EventValidation以某种方式手动验证它。但我也不知道该怎么做。而且我不知道为什么如果设置为false,我的所有其他帖子值都应该为null。这是我的对话框标记...FileUploadEnableEventValidation

 <div class="divDialog" style="display: none">
            <table style="width: 100%;">
                <tr>
                    <td>First Name: <asp:TextBox ID="txtFirstName" runat="server" Text=""></asp:TextBox></td>
                    <td>Last Name: <asp:TextBox ID="txtLastName" runat="server" Text=""></asp:TextBox></td>
                </tr>
                <tr>
                    <td>
                        How Old are You?
                        <asp:DropDownList ID="ddlAge" runat="server">
                            <asp:ListItem Value="1">1</asp:ListItem>
                            <asp:ListItem Value="2">2</asp:ListItem>
                            <asp:ListItem Value="3">3</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>
                        How Many Siblings do You Have?
                        <asp:DropDownList ID="ddlNumberSiblings" runat="server">
                            <asp:ListItem Value="1">1</asp:ListItem>
                            <asp:ListItem Value="2">2</asp:ListItem>
                            <asp:ListItem Value="3">3</asp:ListItem>
                            <asp:ListItem Value="4">4</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        What is your birthday?
                        <input type="text" id="datepicker" name="datepicker" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Please Choose a Picture to Upload:
                        <asp:FileUpload ID="fupUserPicture" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="forcebtnHiddenClick(); return false;" />
                    </td>
                </tr>
            </table>
        </div>

编辑:另外,这可能是相关的,对话框 div 在创建后附加到表单内部的 div 中。这是表单和 div 标记...

<form id="frmDialog" runat="server">
        <asp:Button ID="btnDisplayDialog" runat="server" Text="Click to Display Login Dialog" OnClientClick="showDialog(); return false;" />
        <div class="divInnerForm"></div>

...

</div>
<asp:Button ID="btnHidden" runat="server" Text="" Visible="false" ClientIDMode="Predictable"  OnClick="btnHidden_Click"/>

..这是jQuery脚本...

function showDialog() {
    $('.divDialog').dialog({
        modal: true, show: 'slide', width: 500,
        open: function (event, ui) {
            $('.divInnerForm').append($(this).parent());
        }
    });
}
4

1 回答 1

0

The problem might be nested form tags. Since you are using asp.net webform, i assume you have a

 <form runat="server">

tag enclosing the body of the page. And since the plugin creates a form tag around a div, you may have nested form tags i.e. a form tag inside of another form tag. And since nested forms are not html complaint, the browsers behave weirdly processing those.

Hope this helps.

于 2013-05-09T20:10:10.850 回答