how to set contol property in asp.net

后端 未结 2 667
忘掉有多难
忘掉有多难 2020-12-11 11:56

Very simple and stupid question.

i have a page class

public partial class ProtectWayItem : System.Web.UI.UserControl
    {
        public int Count {         


        
2条回答
  •  臣服心动
    2020-12-11 12:30

    You have to use = instead #

    And if you want to call with the # sign then you need to call a DataBind() method..

    protected void Page_PreRenderComplete(object sender, EventArgs e)
    {
        DataBind();
    }
    

    here is what each expression means

    • 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.

    For a better understanding, please check out this link: The difference between <%= and <%# in ASP.NET

提交回复
热议问题