[英]Close FaceBox from code behind
I am having trouble closing jQuery Facebox from code behind. 我无法从后面的代码关闭jQuery Facebox。 I am inserting a new record through FaceBox, on successful insertion the FaceBox needs to be closed.
我正在通过FaceBox插入新记录,成功插入后需要关闭FaceBox。 How can i achieve this?
我怎样才能做到这一点?
Facebox exposes some events, one of them is facebox.close
. Facebox公开了一些事件,其中之一是
facebox.close
。 So, you could do something like this: 因此,您可以执行以下操作:
function add_record() {
// ... add the record here ...
jQuery(document).trigger('close.facebox');
//or: $(document).trigger('close.facebox');
}
That should close the facebox for you. 那应该为您关闭facebox。
EDIT: To do this via code-behind, it looks like you'll need to write the actual javascript from your code-behind page. 编辑:要通过后台代码执行此操作,似乎您需要从后台代码页编写实际的javascript。 I'm not a .NET programmer, but this question looks like it might point you in the right direction: how to write javascript in asp.net in code behind using C#
我不是.NET程序员,但是这个问题似乎可以为您指明正确的方向: 如何使用C#在后台使用代码在ASP.NET中编写JavaScript
The key is that if you trigger the close.facebox
event, Facebox will close. 关键是,如果触发
close.facebox
事件,则Facebox将关闭。
Solved: 解决了:
Aspx page: Aspx页面:
Aspx.cs page: Aspx.cs页面:
Page page = HttpContext.Current.Handler as Page; 页面page = HttpContext.Current.Handler作为Page; if (page != null) { ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "close_facebox()", true);
if(page!= null){ScriptManager.RegisterStartupScript(page,page.GetType(),“ err_msg”,“ close_facebox()”,true); }
}
Js function: js功能:
function close_facebox() { $('#addlink').css('display', 'none'); 函数close_facebox(){$('#addlink')。css('display','none'); $('#addlink').overlay().close();
$('#addlink')。overlay()。close(); }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.