<p>Basically I would like to find a way to ddo something like:</p>

<pre><code>&lt;asp:Label ID="lID" runat="server" AssociatedControlID="txtId" Text="&lt;%# MyProperty %&gt;"&gt;&lt;/asp:Label&gt;
</code></pre>

<p>I know I could set it from code behind (writing lId.Text = MyProperty), but I'd prefer doing it in the markup and I just can't seem to find the solution.
(MyProperty is a string property)
cheers</p>

[{'answer_id': 73507, 'author': 'Akselsson', 'author_id': 8862, 'author_profile': 'https://Stackoverflow.com/users/8862', 'pm_score': 0, 'selected': False, 'text': '<p>Call lID.Databind() from code-behind</p>\n'}, {'answer_id': 73513, 'author': 'John Sheehan', 'author_id': 1786, 'author_profile': 'https://Stackoverflow.com/users/1786', 'pm_score': 2, 'selected': False, 'text': '<p>Leave the markup as is and make a call to Page.DataBind(); in your code behind.</p>\n'}, {'answer_id': 73558, 'author': 'Serhat Ozgel', 'author_id': 31505, 'author_profile': 'https://Stackoverflow.com/users/31505', 'pm_score': 2, 'selected': False, 'text': '<pre><code>&lt;asp:Label id="lID" runat="server"&gt;&lt;%= MyProperty %&gt;&lt;/asp:Label&gt;\n</code></pre>\n\n<p>since asp.net tags do not allow &lt;% %> constructs, you cannot use Text="&lt;%= MyProperty %>".</p>\n'}, {'answer_id': 73585, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 0, 'selected': False, 'text': '<pre><code>&lt;div&gt; &lt;%=MyProperty"%&gt;&lt;/div&gt;\n</code></pre>\n'}, {'answer_id': 74054, 'author': 'Mark S. Rasmussen', 'author_id': 12469, 'author_profile': 'https://Stackoverflow.com/users/12469', 'pm_score': 4, 'selected': False, 'text': '<p>You can do </p>\n\n<pre><code>&lt;asp:Label runat="server" Text=\'&lt;%# MyProperty %&gt;\' /&gt;\n</code></pre>\n\n<p>And then a Page.DataBind() in the codebehind.</p>\n'}, {'answer_id': 75080, 'author': 'Frederik Vig', 'author_id': 9819, 'author_profile': 'https://Stackoverflow.com/users/9819', 'pm_score': 0, 'selected': False, 'text': "<p>When you use &lt;%# MyProperty %> declaration you need to databind it, but when using &lt;%= MyProperty %> you don't (which is similar to just writing Response.Write(MyProperty).</p>\n"}, {'answer_id': 75235, 'author': 'mrflippy', 'author_id': 13292, 'author_profile': 'https://Stackoverflow.com/users/13292', 'pm_score': 4, 'selected': True, 'text': '<p>Code expressions are an option as well. These can be used inside of quotes in ASP tags, unlike standard &lt;%= %> tags.</p>\n\n<p>The general syntax is:</p>\n\n<pre><code>&lt;%$ resources: ResourceKey %&gt;\n</code></pre>\n\n<p>There is a built-in expression for appSettings:</p>\n\n<pre><code>&lt;%$ appSettings: AppSettingsKey %&gt;\n</code></pre>\n\n<p>More info on this here: <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx" rel="noreferrer">http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx</a></p>\n'}, {'answer_id': 2968964, 'author': 'Brian', 'author_id': 357836, 'author_profile': 'https://Stackoverflow.com/users/357836', 'pm_score': 0, 'selected': False, 'text': '<p>You can do this: </p>\n\n<pre><code>&lt;asp:Label ID="lblCurrentTime" runat="server"&gt;\n    Last update: &lt;%=DateTime.Now.ToString()%&gt;\n&lt;/asp:Label&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/73484', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1613872/']