创建用户控件如下:

前台页面代码如下:

View Code
 1 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Content.ascx.cs" Inherits="WLaw.Vip.Help.Content" %>
2
3
4 <div >
5 <p
6
7       <span>
8   <asp:Label ID="lblTitle" runat="server" Text=""> </asp:Label>
9
10       </span>
11 </p>
12 <asp:Label ID="lblFullContent" runat="server" Text=""> </asp:Label>
13 </div>

 

 服务器端代码:

   

       public HelpInfo hif;
public HelpContentInfo HelpContent;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PageInit();
}

}
private void PageInit()
{
if (hif == null)
{
return;
}
lblTitle.Text = hif.Title;
lblFullContent.Text = HelpContent.FullContent;
}

 

使用用户控件

在页面中注册用户控件

<%@ Register  Src="~/Help/Content.ascx" TagName="UserContorl" TagPrefix="USContent" %>

调用用户控件:

 <UC:UserContorl runat="server" ID="LeftProServer1" />

服务端代码:

View Code
 1   protected void Page_Load(object sender, EventArgs e)
2 {
3 if (!IsPostBack)
4 {
5 int HelpId = Convert.ToInt32(Request["hId"]);
6 HelpInfo hp = HelpBiz.Get(HelpId);
7 HelpContentInfo HelpContent = HelpContentBiz.Get(HelpId);
8 USContent1.hif = hp;
9 USContent1.HelpContent = HelpContent;
10
11 _title.InnerText = hp.Title;
12 }
13 }

 


 



相关文章:

  • 2021-04-10
  • 2021-09-26
  • 2021-06-25
  • 2021-07-21
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-05-22
  • 2022-01-06
  • 2022-12-23
  • 2021-12-11
相关资源
相似解决方案