【发布时间】:2012-10-16 03:22:31
【问题描述】:
首先,为这个问题的长度道歉!
我有一个页面,上面有几个 Web 用户控件,其中两个有些相互依赖。在理想的世界中,它们可以是一个控件,但出于各种原因,它们必须是两个控件。
我需要根据另一个控件中下拉列表的操作来更新其中一个控件中的更新面板,如下所述。
为此,我们将控件称为 JobControl 和 CallControl。 JobControl 包含一个下拉列表,它是 AJAXControlToolkit 中级联下拉列表的一部分。当此下拉列表具有选定的索引更改时,我想更新 CallControl 中的控制面板。
CallControl 公开它的更新面板:
public UpdatePanel UpdatePanel
{
get { return updCall; }
}
JobControl 有一个公共成员 AssociatedCallControl
private ServiceCallControl associatedCallControl;
public ServiceCallControl AssociatedCallControl
{
get { return associatedCallControl; }
set { associatedCallControl = value; }
}
然后在包含控件的页面的 OnLoad 事件中将两者关联在一起。
这个 SO 问题:Update Panel error: Control with the ID "xxx" could not be found in the UpdatePanel 让我在 JobControl 的 onload 事件中尝试了这个:
if (associatedCallControl != null)
{
AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
string s = ddCallGroup.ClientID;
//ddCallGroup is the dropdown I want to trigger the update of the CallControl
trig.ControlID = ddCallGroup.ClientID; //Also Tried ddCallGroup.ID
trig.EventName = "CallGroupChanged";
associatedCallControl.UpdatePanel.Triggers.Add(trig);
}
以下也添加到 JobControl 中
public void CallGroupChanged(object sender, EventArgs e)
{
//Stuff to update the CallControl panel including calling update();
associatedCallControl.RefreshMehods(int.Parse(ddCallGroup.SelectedValue));
}
悬停在这一切之后我仍然得到A control with ID 'TabContainer1_tabJob_ctrlJob_ddCallGroup' could not be found for the trigger in UpdatePanel 'updCall'.
我在尝试不可能的事情吗?我是不是走错了路,还是我错过了什么?
【问题讨论】:
标签: c# asp.net updatepanel webusercontrol