Syntax = <% # ...%> - data binding syntax used to bind values ββto manage properties when calling the DataBind method.
You need to call a DataBind - either Page.DataBind to bind all the controls on your page, or this.DataBind () to bind only a shortcut. For instance. add the following to the Page_Load event handler:
<asp:Literal ID="ltUserName" runat="server" Text='<%# Session["UserName"]%>'></asp:Literal> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["UserName"] = "Sample"; this.DataBind(); } }
source share