Quick ASP.NET Tip
We've all got time for a quickie, right? Well here you go. Everyone and their mom (or not) may already do this already, but...
Whenever I have some text to display on a page and the text is dynamic, my first thought is to just dump it out:
<b>Name:</b> <asp:literal id="litName" runat="server"></asp:literal>
Back in your code, you then say:
litName.Text = User.FirstName & " " & User.LastName
or something like that. Typically though, I actually do it like this:
<asp:literal id="litName" runat="server"><b>Name:</b> {0} {1}</asp:literal>
Then the code of the page is like this:
litName.Text = String.Format(litName.Text, User.FirstName, User.LastName)
Main reason I do this is to plan for change. If the designer wants to change something like say show LastName, FirstName just change the format and s/he's done. No recompiling, just save and run and done. You might ask why I included the header in there. Mostly just because it makes me feel better. Keeping all related text in the same literal. In the first example, I as the developer would've had to make the change for the design in code, which IMO, sucks! By having as much as possible in the ASPX related to formatting, a designer can separately make changes in their editor of choice and test it without having to ask me for new dll's.