我有一個用戶控件,有一個GridView
,當用戶點擊這個GridView
中的一行時,函數OnSelectedIndexChanged
被調用,我想在這種情況發生後彈出一個模式。我使用ScriptManager
來調用腳本$('#seasonInfoModal').modal()
,它在打開模式中工作。問題是,打開在同一用戶控件中定義的模式時,它不起作用。模式在page.aspx
內部時打開,但在控制內部時不打開.ascx
。我已經把所有東西都正確地連接起來,並省略了一些細節。這裏是整個代碼是什麼樣子在gridview行點擊打開模態
主要page.aspx
<%@ Page Title="" Language="C#" ... %>
<%@ Register Src="~/Controls/MyControl.ascx" TagPrefix="ACT" TagName="GeneralADM" %>
<ACT:GeneralADM runat="server"" />
MyControl.ascx
<%@ Language="C#" AutoWireUP="true" Codebehind="" Inherits="" %>
<div runat="server">
<!-- Seasonal Info-->
<div runat="server" id="seasonInfoModal" class="modal fade" role="dialog" draggable="true">
</div>
<!-- End seasonal info-->
<!-- Start of Season Edit Modal -->
<div id="seasonEditInfo" class="modal fade" role="dialog" draggable="false">
</div>
<!-- End of Season Edit Modal -->
<asp:GridView>
</asp:GridView>
</div>
在後面的代碼我嘗試打開該模式是這樣
MyControl。 ascx.cs
protected void OnSelectedIndexChanged(object sender, GridViewEventArgs e){
ScriptManager.RegisterStartupScript(this,
this.GetType(),
"seasonInfoModal",
"$('#seasonInfoModal').modal();",
true);
}
問題
#seasonInfoModal
不會彈出,而是彈出一個新的模式,其中沒有任何內容,屏幕會在點擊時變暗。當我將#seasonInfoModal
從控件中拉出到插入控件本身的頁面時,實際上彈出了模式。
問題
我怎樣才能打開模態#seasonInfoModal
當它從該控件的代碼隱藏控制內專門從裏面OnSelectedIndexChanged
功能?
你真的*需要*從服務器端打開彈出窗口嗎?你真的需要UpdatePanel嗎?他們只是把事情弄得一團糟。 – mason
@mason我需要弄清楚如何在用戶控件中打開模式。 –
問題是沒有提供任何類型的信息,即正在使用哪種模式對話框,沒有關於正在嘗試打開模式的事件的詳細信息。 – kaushalparik27