What is the difference between the following?
<asp:Label runat="server">Hello World</asp:Label>
<asp:Label runat="server" Text="Hello World"></asp:Label>
UPDATED:
If they are exactly the same then why does
<asp:Label ID="Label1" runat="server">
There were <%#transactionCount%> transactions today
</asp:Label>
bind correctly when using single-value databinding and displays the correct value for transactionCount, while…
<asp:Label ID="Label1" runat="server" Text="There were <%#transactionCount%> transactions today">
</asp:Label>
does not show a value for transactionCount in the page?
UPDATED AGAIN:
I understand the points being made about using the Literal controls. I shall slap my face accordingly – but it still doesn’t solve the problem – though is perhaps getting closer to a solution.
If I use…
<asp:Literal ID="Label1" runat="server" Text="<%#transactionCount%>"></asp:Literal>
…I see transactionCount’s value show up in the web page.
On the other hand, if I put any character or word in front of the single-value databinding field e.g.
<asp:Literal ID="Label1" runat="server" Text="No. <%#transactionCount%>"></asp:Literal>
…transactionCount does not appear.
They will render the same in your final HTML. However the
Textattribute is useful for programmatically setting the displayed text in your code behind.