我正在使用ASP.NET和C#。我想弹出这个小屏幕,然后当点击OK按钮时,我想根据弹出窗口的输入更新主屏幕。听起来应该是常规的事情。有可能,如果可能,怎么样?
<cc1:modalpopupextender id="ModalPopupExtender1" runat="server"
cancelcontrolid="btnCancel" okcontrolid="btnOkay"
targetcontrolid="txtCosCodeExpCode" popupcontrolid="Panel1"
popupdraghandlecontrolid="PopupHeader" drag="true"
backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>
<asp:panel id="Panel1" style="display: none" runat="server">
<div class="CostCentreExpenseCodePopup" style="background-color:White ; border-style :solid;">
<div class="PopupHeader" id="PopupHeader">Select Cost Centre / Expense Code</div>
<div class="PopupBody">
<p>Cost Centre<asp:DropDownList
ID="ddlCostCentres1"
runat="server"
CssClass="SVSComboBox1"
AppendDataBoundItems ="True"
AutoPostBack="True"
style = "width :152px;"
OnSelectedIndexChanged="ddlCostCentres1_SelectedIndexChanged">
<asp:ListItem Text="Please select" Value="0"></asp:ListItem>
</asp:DropDownList></p>
<p>Expense Code <asp:DropDownList ID="ddlExpCode1" runat="server" CssClass="SVSComboBox1" style = "width :152px;"
AppendDataBoundItems ="True" Enabled="False" Visible ="False">
<asp:ListItem Text="Please select" Value="0"></asp:ListItem>
</asp:DropDownList></p>
</div>
<div class="Controls">
<input id="btnOkay" type="button" value="Done" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
答案 0 :(得分:1)
不要设置OkControlID
,而是在服务器端使用ModalPopupExtender1.Hide()
。然后,您可以先调用更新代码。
您还应该使用服务器按钮而不是<input id="btnOkay" type="button" value="Done" />
来处理他们的点击事件。
答案 1 :(得分:0)
首先将asp:Button
添加为Ok按钮,然后在aspx.cs页面中添加click事件,如下所述:
<强> ASPX:强>
<asp:Button runat="server" ID="btnOkay" Text="OK" OnClick="btnOkay_Click"/>
<强> ASPX.cs 强>
protected void btnOkay_Click(object sender, EventArgs e)
{
// Code to write on ok click event
}
然后从模态弹出扩展程序中删除okcontrolid="btnOkay"
。