I ‘m trying to make a “login information” on the top panel, like “Welcome Back XXX”, so I use
<% Response.Write(Session["username"]); %>
inside the aspx page.
It works, but is there anyway to use the variable directly without Response.Write here? It seems unnecessary.
You can do it like this:
And if you use ASP.NET 4.0 you can automatically HTML encode the value by using this syntax: