Joyin
Joyin

Reputation: 295

Displaying an image until a certain date using asp.net

I'm trying to display an announcement on website. I hope it can automatically stop showing on, say Feb 1st 2014. Anybody knows how to implement it?

Upvotes: 0

Views: 112

Answers (2)

Majid
Majid

Reputation: 14253

ASPX:

<img id="ann" src="../img/banner.jpg" alt="ann" runat="server" Visible="false"/>

Code behind:

if(DateTime.Now< new DateTime(2014,2,1))
   ann.Visible= true;

Upvotes: 0

Alborz
Alborz

Reputation: 6903

Use the following code in page_load of your page:

yourAnnouncementControl.Visible = (DateTime.Now < DateTime.Parse("2014/02/01"));

Be careful about DateTime format in parse method.

Upvotes: 1

Related Questions