我试图在运行时在自定义控件中向我的控件集合添加一个ConfirmButtonExtender,但无法弄清楚为什么扩展程序不会连接到同一CreateChildControls方法中添加到控件集合的按钮。我做了一个简单的测试,并明确地向aspx页面添加了一个按钮,然后在该页面的.cs文件的PreRender中动态创建了扩展器,但它仍然无效。似乎让这个工作的唯一方法是在.aspx页面上有实际的标签。
我错过了什么吗?
protected virtual void CreateChildControls(System.Resources.ResourceManager rm)
{
valValidationSummary = new ValidationSummary();
valValidationSummary.ID = "valValidationSummary";
valValidationSummary.ShowSummary = true;
valValidationSummary.HeaderText = rm.GetString("ValidationSummary");
valValidationSummary.CssClass = "error";
btnGetRates = new LocalizedButton();
btnGetRates.ID = "btnGetStats";
btnGetRates.TextResource = rm.GetString("SubmitButton");
btnGetRates.Text = rm.GetString("SubmitButton");
btnGetRates.CssClass = "inputfield";
btnGetRates.Click += new System.EventHandler(OnSubmitButton_Click);
btnConfirmation = new ConfirmButtonExtender();
btnConfirmation.ID = "rfBtnSubmit_Confirm";
btnConfirmation.ConfirmText = rm.GetString("BAUConfrimation");
btnConfirmation.TargetControlID = "btnGetStats";
this.Controls.Add(btnConfirmation);
this.Controls.Add(valValidationSummary);
this.Controls.Add(btnGetRates);
}
答案 0 :(得分:0)