我在 WebForms 中有一个 jQuery 脚本,我试图在按钮单击事件上显示一条消息。我的文件script
中有,我.aspx
在代码隐藏中调用它。confirm
问题是如果用户单击而不是cancel
按钮,我如何重定向?
.ASPX 脚本:
<script type="text/javascript">
$(window).unload(function () {
CloseWindow();
})
//var newEmployeeDetail = document.getElementById(hfNe)
function confirmAppointEmployee() {
debugger;
Messi.ask("Employee appointed successfully",
function (val) {
if (val == false) {
$("[id*=Cancel]").click();
}
else {
$("[id*=Confirm]").click();
}
}, {
buttons: [{ id: '0', label: 'Confirm', val: true, 'class': 'btn-primary' }, { id: '0', label: 'Cancel', val: false }]
});
}
</script>
代码背后:
ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script>confirmQuickAppointEmployee()</script>");
下面的代码是重定向用户需要调用的字符串。
private string PersonalInformationDetailUrl = Company.Framework.SmartNavigationPersonnel.SmartNavigation.GetUrlByPageName(Company.Framework.SmartNavigationPersonnel.SmartNavigation.PageNameList.PersonalInformationDetail) + "?AllowAddOption=true&AllowDeleteOption=true&RefreshMenuPage=true";
我尝试了以下方法,但cancel
和confirm
按钮都做同样的事情。
var confirm = "$(document).ready(function(){ new Messi('Employee appointed successfully', " +
"{title: 'Title', buttons: [{id: 0, label: 'Close', val: 'false'},{id: 0, label: 'Confirm', val: 'true'}], " +
"callback: function(val) { window.location.href = '" + Functions.FixClientUrl(PersonalInformationDetailUrl) + "' }}); });";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm", confirm, true);