想自己做个留言版,想了下原来的方法都有在页面上面写信息,想换种角度试试,把代码都写到 Codebehind,想了半天就用了WEB控件,动态添加WEB控件时候需要赋值给它。下面就是一点体会。
Control UInfo=LoadControl("listInfo.ascx");
((listInfo)UInfo).ShowAddress(UMessageINFO);
this.PnlInfo.Controls.Add(UInfo);
可能很简单,但是需要摸索。
本文介绍了一种在 ASP.NET 中利用 CodeBehind 动态加载 Web 控件并进行信息展示的方法。通过 LoadControl 方法加载 ascx 用户控件,并将其添加到 Panel 控件中实现动态内容更新。
想自己做个留言版,想了下原来的方法都有在页面上面写信息,想换种角度试试,把代码都写到 Codebehind,想了半天就用了WEB控件,动态添加WEB控件时候需要赋值给它。下面就是一点体会。
Control UInfo=LoadControl("listInfo.ascx");
((listInfo)UInfo).ShowAddress(UMessageINFO);
this.PnlInfo.Controls.Add(UInfo);
可能很简单,但是需要摸索。

被折叠的 条评论
为什么被折叠?