我有一个 jquery ui 对话框,其中包含一堆 asp.net 控件。对话框中还有一个 runat="server" 按钮,用于将表单发送到服务器。不幸的是,这在 IE 中不起作用。在 Chrome 中,它按预期工作。以下是相关的代码片段...
$("#applicationFormDialog").dialog({
autoOpen: false,
width: 780,
height: 550,
title: 'Please enter your career details',
open: function (type, data) {
$(".uploadYourResume").css('display', 'none');
clearAllControls();
var indexToSelect = $('#applicationFormDialog').data('indexVal');
$("#" + "<%=ddlPosition.ClientID %>" + " option")[indexToSelect].selected = true;
debugger;
$(this).parent().appendTo($("form:first"));
},
beforeClose: function (event, ui) {
clearAllControls();
},
resizable: false
});
jQuery UI 版本 = 1.10.1 jQuery 版本 = 1.9.1
让我知道您是否还有其他需要。
更新:如果我只是简单地使用 runat='server' 放置一个普通的提交按钮,这可以工作,但是我在提交之前在客户端验证表单,这就是我认为问题所在。这是客户端验证方法。
function validateForm() {
// Clear all error divs...
$(".errorSpan").css('display', 'none');
// Build the array.
var arrayOfCtrls = new Array();
arrayOfCtrls.push(new control("<%= txtName.ClientID %>", "", "textbox", 0)); // Name
arrayOfCtrls.push(new control("<%= txtEmail.ClientID %>", "", "textbox", 0)); // Email
arrayOfCtrls.push(new control("<%= txtCity.ClientID %>", "", "textbox", 0)); // City
arrayOfCtrls.push(new control("<%= ddlState.ClientID %>", "", "dropdown", 0)); // State
arrayOfCtrls.push(new control("<%= uploadResume.ClientID %>", "fileUploadErrorSpan", "file", 0)); // Resume
arrayOfCtrls.push(new control("<%= ddlPosition.ClientID %>", "", "dropdown", 0)); // Position
arrayOfCtrls.push(new control("<%= ddlQualification.ClientID %>", "", "dropdown", 0)); // Qualification
arrayOfCtrls.push(new control("<%= ddlExperience.ClientID %>", "", "dropdown", 0)); // Experience
if ($("#" + "<%=ddlExperience.ClientID %>").val() != "Fresher") {
arrayOfCtrls.push(new control("<%= txtCurrCompany.ClientID %>", "", "textbox", 0)); // Current Company
arrayOfCtrls.push(new control("<%= txtWorkingSince.ClientID %>", "", "textbox", 0)); // Working since
arrayOfCtrls.push(new control("<%= txtCurrLocation.ClientID %>", "", "textbox", 0)); // Current Location
}
if (!controlsToValidate(arrayOfCtrls)) {
return false;
}
// Check email address
if (!validEmail((document.getElementById("<%= txtEmail.ClientID %>")).value)) {
document.getElementById("<%= txtEmail.ClientID %>").focus();
document.getElementById("<%= txtEmail.ClientID %>").title = "Please enter a proper email address.";
return false;
}
return true;
}
这些是对话框上的按钮
<asp:Button ID="btnSubmitForm" runat="server" Text="Submit" OnClientClick="return validateForm()" OnClick="submitForm_Click" />
<input type="button" id="btnClearFields" value="Clear" />
<asp:Button ID="btnClear" runat="server"/>
我添加的最后一个按钮用于检查回发是否适用于普通按钮,并且工作正常。
更新#2:有一个问题,在我从脚本返回 true 后,一些 jquery 方法不断被调用。