Revision: 21783
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 21, 2009 05:36 by tomaszsimon
Initial Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <p>Equals: <%= this.TestValue %></p> <p>Pound: <%# this.TestValue %></p> <p>Equals label: <asp:Label runat="server" ID="_equals" Text="<%= this.TestValue %>" /></p> <p>Pound label: <asp:Label runat="server" ID="_pound" Text="<%# this.TestValue %>" /></p> </div> </form> </body> </html> //And the code behind is: public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { _testValue = "2"; } protected void Page_PreRenderComplete(object sender, EventArgs e) { // DataBind(); _testValue = "3"; } public string TestValue { get { return _testValue; } } private string _testValue = "1"; }
Initial URL
http://blogs.msdn.com/dancre/archive/2007/02/13/the-difference-between-lt-and-lt-in-asp-net.aspx
Initial Description
* 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 controls add DataBind() in PreRender Event
Initial Title
The difference between <%= and <%# in ASP.NET
Initial Tags
Initial Language
C#