【发布时间】:2013-05-09 18:41:00
【问题描述】:
所以我在 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 控件中设置的图像被发布,但我所有其他发布的值都返回为空。所以我认为我要么需要为FileUpload 控件禁用EventValidation,只是,要么以某种方式手动验证它。但我也不知道该怎么做。而且我不知道如果EnableEventValidation 设置为false,为什么我的所有其他帖子值都应该为null。这是我的对话框标记...
<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());
}
});
}
【问题讨论】:
-
您的对话框是否在更新面板中?
-
不,它在表单内部的一个 div 中,但它必须在创建后使用 jQuery 脚本附加到该 div。我现在将发布该代码/标记...
-
而且只是为了提高意识,您是否尝试删除这种“动态”行为并观察组件响应?
-
如果我删除脚本 jQuery 将对话框移到表单之外(它最初在标记中),所以没有 showDialog() 脚本就无法发布。
标签: jquery asp.net validation events post