在 span 单击时从不同的 ascx 页面调用 ascx 内的模态
Call modal inside ascx from different ascx page on span click
我在 page1.ascx 中有一个模态,需要在从 page2.ascx 进行跨度点击时调用。我无法让它工作。请帮忙。
Page2.ascx
<ul class="nav metismenu" id="side-menu">
<li id="nav_callback" runat="server">
<a><i class="fa fa-phone"></i> <span class="nav-label spmodal" onclick="open_request_callback()">Request Callback</span></a>
</li>
</ul>
Page2.ascx(JS函数)
function open_request_callback() {
$get("<%=btn_open_request_callback.ClientID %>").click();
}
Page2.ascx(asp:点击按钮):
<div class="hidden">
<asp:Button ID="btn_open_request_callback" runat="server" OnClick="btn_open_request_callback_Click" />
</div>
<telerik:RadAjaxManagerProxy ID="ram" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btn_open_request_callback">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="btn_open_request_callback" UpdatePanelRenderMode="Inline"/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
Page2.ascx(代码隐藏):
protected void btn_open_request_callback_Click(object sender, EventArgs e)
{
request_callback callback = new request_callback();
callback.open_callback_model();
}
Page1.ascx(代码隐藏):- 不调用 Javascript 函数
public void open_callback_model()
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "open_callback_modal", "open_callback_modal();", true);
}
Page1.ascx(JS函数)
function open_callback_modal() {
alert('You clicked the button!')
$get("btn_open_callback").click();
}
Page1.ascx(跨度点击):
<span id="btn_open_callback" data-toggle="modal" data-target="#mdl_request_callback"></span>
需要注册控件:
<%@ Register Src="~/controls/request_callback.ascx" TagPrefix="uc1" TagName="request_callback" %>
<uc1:request_callback runat="server" id="request_callback" />
我在 page1.ascx 中有一个模态,需要在从 page2.ascx 进行跨度点击时调用。我无法让它工作。请帮忙。
Page2.ascx
<ul class="nav metismenu" id="side-menu">
<li id="nav_callback" runat="server">
<a><i class="fa fa-phone"></i> <span class="nav-label spmodal" onclick="open_request_callback()">Request Callback</span></a>
</li>
</ul>
Page2.ascx(JS函数)
function open_request_callback() {
$get("<%=btn_open_request_callback.ClientID %>").click();
}
Page2.ascx(asp:点击按钮):
<div class="hidden">
<asp:Button ID="btn_open_request_callback" runat="server" OnClick="btn_open_request_callback_Click" />
</div>
<telerik:RadAjaxManagerProxy ID="ram" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btn_open_request_callback">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="btn_open_request_callback" UpdatePanelRenderMode="Inline"/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
Page2.ascx(代码隐藏):
protected void btn_open_request_callback_Click(object sender, EventArgs e)
{
request_callback callback = new request_callback();
callback.open_callback_model();
}
Page1.ascx(代码隐藏):- 不调用 Javascript 函数
public void open_callback_model()
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "open_callback_modal", "open_callback_modal();", true);
}
Page1.ascx(JS函数)
function open_callback_modal() {
alert('You clicked the button!')
$get("btn_open_callback").click();
}
Page1.ascx(跨度点击):
<span id="btn_open_callback" data-toggle="modal" data-target="#mdl_request_callback"></span>
需要注册控件:
<%@ Register Src="~/controls/request_callback.ascx" TagPrefix="uc1" TagName="request_callback" %>
<uc1:request_callback runat="server" id="request_callback" />