我有一個名爲DateTimeUC用戶控制,在它的標記兩個文本框:控件沒有出現在動態創建用戶控制
<asp:TextBox ID="dateTextBox" runat="server"></asp:TextBox>
<asp:TextBox ID="timeTextBox" runat="server"></asp:TextBox>
我動態創建中的其他用戶控制這個控制:
Controls.Add(GenerateDateTime(parameter));
private DateTimeUC GenerateDateTime(SomeParameter parameter)
{
DateTimeUC uc = new DateTimeUC();
uc.ID = parameter.Name;
return uc;
}
但是當我渲染頁面時,DateTimeUC不渲染任何東西。我檢查它是這樣的:
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
StringBuilder builder = new StringBuilder();
StringWriter swriter = new StringWriter(builder);
HtmlTextWriter hwriter = new HtmlTextWriter(swriter);
base.Render(hwriter);
string s = builder.ToString();
}
s是空的,Controls.Count是0.我做錯了什麼?
一直在尋找的答案,這一切的一天。謝謝! – McMuttons 2010-09-20 12:58:09