[英]How to close a simple modal dialog on a button click?
Here i am trying to close a modal dialog on a button click but it is not closing the dialog.Here is my code 在这里,我试图关闭按钮单击模式对话框,但它没有关闭对话框。这是我的代码
function closemodal() {
alert("true");
$.modal.close();
return false;
}
and 和
protected void btnOK_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "closemodal();", true);
}
i need to call a javascript function and after that i need to close that dialog..Any suggestion?? 我需要调用一个javascript函数,之后我需要关闭该对话框。任何建议?
EDIT: 编辑:
$(document).ready(function () {
$('#MainContent_uscRetailParameters_btnOK').click(function (e) {
closemodal();
return false;
});
function closemodal() {
$.modal.close();
}
});
EDIT 2: 编辑2:
$('#CusCatPOPUP .basic').click(function (e)
{
$('#CusCatPOPUP-content').modal();
return false;
}
);
Unless I'm missing the point: 除非我错过了这一点:
$('#MainContent_uscRetailParameters_btnOK').click(function (e) {
MyFunctionCall(); //i.e. call you function here
$.modal.close();
return false;
});
Might be an error elsewhere, check your browser console. 可能是其他地方的错误,请检查您的浏览器控制台。
Created an example: http://jsfiddle.net/eTnJF/ 创建了一个例子: http : //jsfiddle.net/eTnJF/
With code: 使用代码:
$(document).ready(function() {
$('.open').click( function() {
$('#modal').modal();
});
$('.close').click( function() {
closemodal();
return false;
});
function closemodal() {
alert("true");
$.modal.close();
}
});
Which works fine :) 哪个工作正常:)
If you want to simply close the modalpopup then the javascript code is. 如果你想简单地关闭modalpopup,那么javascript代码就是。
var mpu = $find('ModalPopupExtender1');
mpu.hide();
Hope it helps. 希望能帮助到你。
thanks Kamran 谢谢Kamran
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.