ASP.Net ITemplate - ways of declaring

☆樱花仙子☆ 提交于 2019-12-01 07:39:42

It does look like you're declaring the template properly. To actually populate the contents with your own template, you declare it in your markup. Eg:

<MyControl runat="server" ...>
  <MyTemplate>
   ... any standard ASP.NET controls in here
   <asp:Label runat="server" ID="lblName"/>
  </MyTemplate>
</MyControl>

  public void InstantiateIn(Control container) {
      var lblName = container.FindControl("lblName") as Label;
      lblName.Text = "Blah";// set from your data layer or otherwise
      Button b = new Button();
      b.ID = "B";
      container.Controls.Add(b);
  }

Is this what you were looking for?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!