Did you ever met a condition where you want that your asp.net webpage will open only from particular date and particular time to particular date and particular time.Here is the simple code.
First edit web.config file to add key for starting date and ending date :
<location allowOverride="true" inheritInChildApplications="true">
<appSettings>
<add key="frmstartdate" value="02/15/2014 03:30:59 PM " />
<add key="frmenddate" value="03/30/2014 03:30:59 PM " />
</appSettings>
</location>
Very Simple isn't it.Now on WebPage on which restrictions are to be applied.Code is
if ((Convert.ToDateTime(ConfigurationManager.AppSettings.Get("AdmissionFormStartDateTime")) > (System.DateTime.Now))
||
(Convert.ToDateTime(ConfigurationManager.AppSettings.Get("AdmissionFormEndDateTime")) < (System.DateTime.Now)))
{
//make every thing visible false and show message that this form is closed now
}
Done :)
First edit web.config file to add key for starting date and ending date :
<location allowOverride="true" inheritInChildApplications="true">
<appSettings>
<add key="frmstartdate" value="02/15/2014 03:30:59 PM " />
<add key="frmenddate" value="03/30/2014 03:30:59 PM " />
</appSettings>
</location>
Very Simple isn't it.Now on WebPage on which restrictions are to be applied.Code is
if ((Convert.ToDateTime(ConfigurationManager.AppSettings.Get("AdmissionFormStartDateTime")) > (System.DateTime.Now))
||
(Convert.ToDateTime(ConfigurationManager.AppSettings.Get("AdmissionFormEndDateTime")) < (System.DateTime.Now)))
{
//make every thing visible false and show message that this form is closed now
}
Done :)
Comments
Post a Comment