在aspx页面中使用ascx页面的用户控制id



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

所以你没有aspx页与用户控制页的直接关系。在这种情况下,在母版页中创建一个类型为usercontrol

的公共函数
public yourusercontrol getucID()
 {
  return usercontrol_id
 }

现在你可以使用这个函数在你的aspx.cs页面中获取usercontrol id。

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

希望能有所帮助

最新更新