怎样调用web用户控件

如题所述

1)web界面前台代码

2)web界面后台代码

    using System;  

    using System.Collections.Generic;  

    using System.Web;  

    using System.Web.UI;  

    using System.Web.UI.WebControls;  

    namespace UserControlsDemo1  

    {  

    public partial class _Default : System.Web.UI.Page  

    {  

    protected void Page_Load(object sender, EventArgs e)  

    {  

    if (!IsPostBack)  

    {  

    //后台调用用户控件  

    WebUserControl1 webUserControl1 = (WebUserControl1)Page.LoadControl("~/WebUserControl1.ascx");  

    webUserControl1.ID = "webUserControl1";  

    div1.Controls.Add(webUserControl1);  

    }  

    }  

    }  

    }  


温馨提示:答案为网友推荐,仅供参考
相似回答