用户控件中设置属性

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";
    }
}

相关文章:

  • 2021-06-14
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
相关资源
相似解决方案