Regarding these two approaches:
<asp:Label ID="Label1" runat="server"><%# DateTime.Now %></asp:Label>
and
Label1.Text = DateTime.Now.ToString();
Which do you use and why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both are the same.
Personally, I prefer the programmatic approach (number 2) because code-behind more engineered and easier to maintain. Well, this is a simple case where you write the current time, of course, but, in general, it’s better to leave markup for graphics layout and use code as much as possible. In other complex scenario, you will find easier to refactor the code or analyse it with profilers.
Hope to have been of help. Remember, it’s all IMHO 🙂