【问题标题】:Use usercontrol id of ascx page in aspx page在aspx页面中使用ascx页面的usercontrol id
【发布时间】:2014-07-16 01:59:43
【问题描述】:

我有一个用户控件。用户控件包含在母版页中。现在我还有另一个页面是 aspx 页面。aspx 页面正在继承母版页。那么我如何访问 aspx 页面中用户控件的 id。

【问题讨论】:

    标签: c# asp.net user-controls


    【解决方案1】:

    所以你的aspx页面与usercontrol页面没有直接关系。在这种情况下,在usercontrol类型的母版页中创建一个公共函数

    public yourusercontrol getucID()
     {
      return usercontrol_id
     }
    

    现在您可以使用此函数在您的 aspx.cs 页面中获取用户控件 ID。

    yourmaster mst = (yourmaster)Page.Master;
     yourusercontrol yuc = mst.getucID();
     //Now do your stuff with yuc
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 1970-01-01
      相关资源
      最近更新 更多