我知道這與S.O.上的許多其他問題類似。但他們似乎都不適用於這種情況,他們也沒有解決問題。問題是我有一個Modal Popup Control,我根據需要傳遞其他控件。所以當用戶點擊我的用戶界面上的一個按鈕時,他可以用一組內容獲取該模式,然後當點擊另一個按鈕時他會得到不同的內容。一切工作正常,直到我試圖從添加到模式彈出窗口的內容中觸發事件。說我已經盡力解決這個問題並不完全準確,但我已經嘗試了很多。我越來越相信這要麼不能完成,要麼我有一些錯誤的設置。更新面板中的Modalpopup擴展器,誰控制不會觸發的事件
這是此代碼爲更新面板
<input id="dummy" type="button" style="display: none" runat="server" />
<asp:ModalPopupExtender CancelControlID="Close" runat="server" ID="mpeThePopup" TargetControlID="dummy" PopupControlID="pnlModalPopUpPanel" BackgroundCssClass="modalBackground" PopupDragHandleControlID="Title" />
<asp:Panel ID="pnlModalPopUpPanel" runat="server" CssClass="modalPopup" Width="400px" Height="600px">
<asp:UpdatePanel ID="udpInnerUpdatePanel" runat="Server">
<ContentTemplate>
<table id="ContentTableTag" runat="server" cellpadding="0" cellspacing="0" style="width: 100%;
height: 100%;">
<tr>
<td id="Title" runat="server" style="background-color: rgb(79,82,90); text-align: left;
height: 28px; width: 90%; color: White;" nowrap="nowrap">
<h4 style="margin: 0px 0px 0px 5px;">
<asp:Label ID="LblSectionTitle" runat="server" Text="Modal"></asp:Label>
</h4>
</td>
<td id="Close" runat="server" style="background-color: rgb(79,82,90); text-align: right;
height: 28px; width: 10%" nowrap="nowrap">
<asp:ImageButton ID="ibClose" runat="server" Style="margin-right: 5px;" ImageUrl="~/WLImages/MLS/button_close.png"
ToolTip="Close" />
</td>
</tr>
<tr>
<td id="MainContentHolder" colspan="2" align="left" style="top: 0px; bottom: 100%;
vertical-align: top; width: 100%; height: 100%" />
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
這對於我加入到模式彈出的用戶控件的代碼,在其背景有兩個事件觸發,一個是當日歷改變它的日期,還有一個用於檢查複選框項目的時間。
<table id="mainContent" runat="server" visible="false" width="350" height="300">
<tr>
<td>
<asp:label ForeColor="White" runat="server" Text="Exam Date:" />
</td>
<td>
<asp:TextBox ID="txtDate" runat="server" Width="127" ForeColor="Black"
readonly="true" ontextchanged="txtDate_TextChanged"/>
<asp:CalendarExtender ID="CalendarExtender" runat="server"
PopupButtonID="ibtnCalendar" OnClientDateSelectionChanged="checkDate"
TargetControlID="txtDate" onload="LoadCalendar" />
</td>
<td>
<asp:ImageButton ID="ibtnCalendar" ImageUrl="../imgs/btn_calendar.png" Width="20px" runat="server" />
</td>
</tr>
<tr>
<td style="vertical-align: top; padding-top:5px">
<asp:label ForeColor="White" runat="server" Text="Study Days:" />
</td>
<td colspan="2" style="vertical-align: top; padding-top:5px">
<asp:CheckBoxList ID="WeekCheckBox" runat="server" ForeColor="White"
onselectedindexchanged="WeekCheckBox_SelectedIndexChanged">
<asp:ListItem Text="Monday" Value="1" />
<asp:ListItem Text="Tuesday" Value="2" />
<asp:ListItem Text="Wednesday" Value="3" />
<asp:ListItem Text="Thursday" Value="4" />
<asp:ListItem Text="Friday" Value="5" />
<asp:ListItem Text="Saturday" Value="6" />
<asp:ListItem Text="Sunday" Value="7" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<asp:label ForeColor="White" runat="server" Text="Study hours per day:" />
</td>
<td colspan="2">
<asp:TextBox ForeColor="Black" ID="tbStudyHours" runat="server" Width="127px" ReadOnly="true" />
</td>
</tr>
</table>
最後這是我如何將控制附加到模態。
private void GenerateCalendarPopup(ExamDateSelector eds)
{
pnlModalPopUpPanel.BackColor = GUI.Instance.GUIColorElement(GUIElements.color_main);
LblSectionTitle.Text = "Exam Date";
pnlModalPopUpPanel.Height = eds.ControlHeight + 40;
pnlModalPopUpPanel.Width = eds.ControlWidth + 25;
eds.ShowControl = true;
MainContentHolder.Controls.Add(eds);
}
謝謝你的幫助。
我不想創建30個左右獨立的模式彈出窗口,彈出窗口在那裏試圖模仿我們的Windows軟件。我沒有試圖用欺騙手段,只是一遍又一遍地複製同樣的基本事物似乎很愚蠢。這就是說我可能不得不復制粘貼它。 – Siegeon 2012-01-27 22:05:55
然後,我真的在做這些東西(我幾乎沒有任何Web開發經驗)。沒有其他代碼可以顯示你真的... – Siegeon 2012-01-27 22:08:42
不知道你的用例是如何有這麼多的彈出窗口。但我已經使用FancyBox與IFrame模式加載單獨的頁面作爲彈出窗口取得巨大成功。如果需要,您也可以從彈出窗口回到主頁面。這可能會更容易,那麼你現在想做什麼.... – Danthar 2012-01-27 22:11:28