我花了几天时间才弄明白,但是在使用母版页或单独的更新面板时,必须挂接到ResolveControlID事件。
ModalPopupExtender mpeScore = new ModalPopupExtender()
{
ID = "mpeSc",
PopupControlID = popScore.ClientID,
CancelControlID = cancelVote.ClientID,
TargetControlID = btnVote.ID, //will note resolve, done in exception
BackgroundCssClass = "modalBackground",
BehaviorID = "mpeScore"
};
mpeScore.ResolveControlID += mpe_ResolveControlID;
this.Form.Controls.Add(mpeScore);
您可以对所有模式弹出窗口使用相同的处理程序,并解析如下控件
protected void mpe_ResolveControlID(object sender, AjaxControlToolkit.ResolveControlEventArgs e)
{
switch (e.ControlID)
{
case "btnVote":
e.Control = btnVote;
break;
case "btnComDummy":
e.Control = btnComDummy;
break;
}
}
很高兴我能帮助(我)。