[英]Show/Hide Modal Popup in User Control from ASPX behind code
I need to show/hide a reusable modal popup that it is in a UserControlWeb (ascx). 我需要显示/隐藏它在UserControlWeb(ascx)中的可重用模式弹出窗口。
In my ASPX web, I defined the UC: 在我的ASPX网站中,我定义了UC:
<%@ Register TagPrefix="uc" TagName="uc1" Src="~/Controls/modalpopup.ascx" %>
<uc:uc1 ID="ModalPopup1" runat="server" />
I can show/hide the modalpopup with javascript: 我可以使用javascript显示/隐藏modalpopup:
$find('MBehavior').show();
$find('MBehavior').hide();
But, I need to do from behind code of my ASPX web. 但是,我需要从ASPX Web的后台代码执行操作。
It is posible? 有可能吗?
Try the above 试试上面
string script = @" <script type=""text/javascript"">
$find('MBehavior').show();
});</script>";
ClientScript.RegisterStartupScript(Page.GetType(), "", script);
如果页面中有updatepanel,则可以尝试;
ScriptManager.RegisterStartupScript(updatePanelID, updatePanelID.GetType(), Guid.NewGuid().ToString(), "$find('MBehavior').show(); $find('MBehavior').hide();", true);
if you want to to run from aspx: 如果要从aspx运行:
$("#mybutton").click(function(e) {
$find('MBehavior').show();
$find('MBehavior').hide();
e.preventDefault();
});
if from code behind: 如果从后面的代码:
$("#mybutton").click(function(e) {
$.ajax( {
type:'Get',
url:'aspxfilename/mymethod',
success:function(data) {
}
});
e.preventDefault();
});
and in .cs file create a method: 并在.cs文件中创建一个方法:
[WebMethod]
public static string mymethod()
{
//run javascript
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.