.net UserControl用户控件传值

用户控件中设置属性

ascx.cs
 private string tableName;


    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(TableName);
       
    }


    public string TableName
    {
        get { return tableName; }
        set { tableName = value; }
    }

    public void getDB(string TableName)
    {
        tableName = TableName;
    }

 页面代码文件

.cs

public partial class PageCommon : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        //获得父页面
        //Page p = this.Parent.Page;
        //获得父页面的子控件
        UserControl uc = this.FindControl("WebUserPage1") as UserControl;

        WebUserPage1.TableName = "db";
    }
}

posted @ 2009-05-26 15:04  meetweb  阅读(1965)  评论(0编辑  收藏  举报