2013-09-23 31 views
0

我已經創建了一個用於我的asp.net網站(不是mvc)的usercontrol(.ascx)。該控件有幾個文本框,並允許用戶輸入新客戶。它有兩個按鈕,一個用於添加客戶,另一個用於取消控制。我稱顯示通過使用「ModalPopupExtender「與代碼如下所示的控制:知道ModalPopupExtender用戶控件何時關閉

這是一個UpdatePanel:

<asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="hiddenButton" 
PopupControlID="Panel3" BackgroundCssClass="modalBackground" DropShadow="true"/> 

這裏是·Panel3中標記:

<asp:Panel ID="Panel3" runat="server" Style="display: none" CssClass="modalPopup" Width="100%" Height="100%"> 
    <uc3:CustomerForm runat="server" ID="CustomerForm1" ParentUpdatePanel="UpdatePanel1" ErrorDisplayControl="lblErrorMessage"/> 
</asp:Panel> 

當我點擊主頁上的按鈕代碼背後的調用:

ModalPopupExtender2.Show(); 

這顯示我的控制和whe ñ我添加一個新的客戶數據庫更新,所以這一方面的工作正常。我需要做的是增強代碼,以便在添加客戶並關閉用戶控件時,主頁上的客戶下拉列表將加載更新的客戶列表和用戶輸入的客戶。下拉列表是數據綁定的,所以我的問題是,我怎麼知道我的用戶控件何時關閉,以便我可以計算出是否添加了新的客戶,然後重新綁定我的列表並選擇正確的項目?使用asp.net和javascript不是一個我有很多技能的領域,所以請原諒,如果我使用了錯誤的術語。

回答

0

我找到了解決我的問題的方法。在我的用戶,新客戶增加了之後我打電話:

RaiseBubbleEvent(this, new CustomerArgs {OrganisationId = organisationId}); 

在調用頁面的代碼後面我聽泡沫事件:

protected override bool OnBubbleEvent(object sender, EventArgs e) 
{ 
    if (sender is CustomerForm && e is CustomerArgs) 
    { 
     _organisationID = (e as CustomerArgs).OrganisationId.ToString(); 
     DoOrganisationListDataBind(); 
     return true; 
    } 
    return false; 
} 

能正常工作,爲我之後我。不知道這是否是一個很好的方法來做到這一點,但它的工作原理。

相關問題