How do I get to the current users name without doing it in the code-behind, just using the aspx server tags?
In code-behind I can just do this:
Label4.Text = User.Identity.Name.ToString()
But I'm trying to do it without code-behind like this:
<body>
<form id="form1" runat="server">
<div>
1. <asp:Label ID="Label1" runat="server" Text="<% User.Identity.Name %>"/><br />
2. <asp:Label ID="Label2" runat="server" Text="<%= User.Identity.Name %>"/><br />
3. <asp:Label ID="Label3" runat="server" Text="<%# User.Identity.Name %>"/><br />
4. <asp:Label ID="Label4" runat="server" Text="<%= Context.User.Identity.Name %>"/><br />
5. <asp:Label ID="Label5" runat="server" Text='<%# User.Identity.Name %>' /><br />
6. <span runat="server" ID="Span1"><%= User.Identity.Name %></span><br />
7. <asp:LoginName ID="LoginName1" runat="server" /><br />
8. <span><%# User.Identity.Name %></span><br />
9. <span><%= User.Identity.Name %></span><br />
10. <asp:Label ID="Label6" runat="server" Text='<%= User.Identity.Name %>' /><br />
</div>
</form>
</body>
I get the username displayed for lines 6, 7, and 9 but I really want to set a property of a control to this value and not just display it on screen.
Is it possible?
Background: I was whipping up a quick app, dragging and dropping controls on the page, and it turned out that I did it with only having 1 line in code-behind of the page(s). That line was setting the value of a hidden field to the current users name in page load so I could pass the value of that control as a param of a sqlparameter. So I thought that since I was going this route (lots of stuff in aspx that maybe shouldn't be there) I should try to be consistent with it. I don't normally do it this way, but wanted to this time