aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to display Good Morning,Good Afternoon and Good Evening Messages based on time in

Oct 22, 2010

I will explain how to display Good Morning,Good Afternoon and Good Evening Messages based on time in


In some of websites we will see greeting messages like good morning, good afternoon and good evening messages how to display those messages in our website. Basically those messages will display by calculating present time and we can display that greeting messages.

For that first design your aspx page like this  

<html xmlns="">
<head runat="server">
<title>Time Based Greeting Message in</title>
<body onload="">
<form id="form1" runat="server">
<asp:Label ID="lblGreeting" runat="server" />
<asp:Label ID="lblDate" runat="server"/>
After that write the following code in code behind

protected void Page_Load(object sender, EventArgs e)
lblGreeting.Text = "Good Morning";
lblDate.Text = Convert.ToString(DateTime.Now);
else if(DateTime.Now.Hour<17)
lblGreeting.Text = "Good Afternoon";
lblDate.Text = Convert.ToString(DateTime.Now);
lblGreeting.Text = "Good Evening";
lblDate.Text = Convert.ToString(DateTime.Now);

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email
© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.