2011-02-24 51 views

回答

0

我去尋找我的控制不同的方法。我用this方法。我過去曾經使用過這個,不知道爲什麼我沒有早點考慮過它。在我的用戶控件中,我將控件作爲屬性公開。在我的母版頁中,我創建了一個允許我獲取用戶控件實例的屬性。在我的頁面中,我可以調用:Master.UserControlName.PropertyInControl

因此,如果我在用戶控件中公開按鈕或控件,我應該可以將其添加到觸發器集合中。

3

你應該能夠使用Master.FindControl("MySaveButton")從內容頁面中,並將其連接到ScriptManager的觸發列表:

this.MyScriptManager.RegisterAsynchPostBackControl(Master.FindControl("MySaveButton")) 

除非我沒有正確認識的問題。

+0

我需要找到thorugh主機和到用戶控制的,正確的控制?我想這應該是這樣的:Master.FindControl( 「用戶控件」)的FindControl( 「TheButton」) – DDiVita 2011-02-24 20:51:23

+0

@DDiVita:正確。 – 2011-02-24 20:53:40

0

檢查第四下來後(標記爲答案)here,它應該幫助。

總之,創建一個PostBackTrigger實例,適當地設置字段,然後添加到UpdatePanelTriggers集合。

例如(來自鏈接網站):

//Creates a new async trigger 
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger(); 

//Sets the control that will trigger a post-back on the UpdatePanel 
trigger.ControlID = "btnCommit"; 

//Sets the event name of the control 
trigger.EventName = "Click"; 

//Adds the trigger to the UpdatePanels' triggers collection 
pnlMain.Triggers.Add(trigger); 
+0

我喜歡這個,但是這個代碼在哪裏?就像我說過的,我有一個母版頁,並且在該母版頁中是一個工具欄用戶控件。該按鈕位於該用戶控件內部。當我基地頁面關閉我的主人,並把設計呢頁我設置控件ID在用戶控制按鈕的ID更新面板? – DDiVita 2011-02-24 20:42:52

相關問題