using <%= %> or <%# %> with runat=server in ASP.NET

回眸只為那壹抹淺笑 提交于 2019-12-05 08:55:58

You should have to use binding expression <%# expr %>.

<cc1:Foo Bar='<%# String.Concat(Fa.La.La,"/otherstuff")%>' runat="server" /> 

and call DataBind() method in code-behind.

public void page_load()
{
  DataBind();
}

Well, first you should be clear to diff between both tags. here are some points i have read and used practically..

  • The <%= expressions are evaluated at render time
  • The <%# expressions are evaluated at DataBind() time and are not evaluated at all if DataBind() is not called.
  • <%# expressions can be used as properties in server-side controls.<%= expressions cannot.

read more it on MSDN Blog

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