2011-02-24 46 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

相关问题