我有一个字符串存储在 DB 中"<asp:panel id='test' runat='server' ></asp:panel>"
。我正在尝试获取这些数据并put it in a div which have runat="server" in it using innerHtml property.
protected void Page_Load(object sender, EventArgs e)
{
Layouts.InnerHtml = GetTemplate();
}
public string GetTemplate()
{
CompassModel.Layout Layout;
using (CompassEntities db = new CompassEntities())
{
Layout = (from q in db.Layouts
where q.LayoutID == 1
select q).SingleOrDefault();
}
return Layout.LayoutHTML;
}
当我尝试使用findcontrol()
方法访问这个动态添加的面板时,它返回 null。
有什么方法可以渲染它以便我可以在运行时访问面板?