C# , Asp.net, SQL Server, .Net , CSS, HTML
Free C#, .Net, Asp.net, css, html and Sql server video tutorial for beginners & intermediate programmers.
Saturday, October 24, 2020
Sunday, September 13, 2020
Saturday, September 7, 2019
How to set an Expiry Date for web application using ASP.NET C#
-----------Web.config -------
<appSettings>
<add key="copyright" value="C# Soft Code © 2019"/>
<add key="RegDate" value="01/01/2018"/>
<add key="ExpDateMess" value="01/01/2020"/>
<add key="ExpDate" value="01/02/2020"/>
</appSettings>
-----------------aspx.cs code file-------------
private void showMessage()
{
DateTime expDate = Convert.ToDateTime(ConfigurationManager.AppSettings["ExpDateMess"].ToString());
DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
TimeSpan t = expDate - currentDate;
double nrOfDays = t.TotalDays;
if (nrOfDays > 0)
{
}
else
{
ClientScript.RegisterStartupScript(typeof(Page), "alertMessage", "<script type='text/javascript'>alert('Your software key is expired. Please contact your software provider for renewal.');</script>");
}
}
protected void lbtnLogin_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtUserName.Text))
{
ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('Please enter user Name..!')</script>");
txtUserName.Focus();
return;
}
if (string.IsNullOrEmpty(txtPassword.Text))
{
ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('Please enter Password ..!')</script>");
txtPassword.Focus();
return;
}
DateTime expDate = Convert.ToDateTime(ConfigurationManager.AppSettings["ExpDate"].ToString());
DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
TimeSpan t = expDate - currentDate;
double nrOfDays = t.TotalDays;
if (nrOfDays > 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('Welcome to C# Soft Code')</script>");
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('Your software key expired. Please contact your software provider for renewal.!')</script>");
}
}
Subscribe to:
Posts (Atom)
Also Read
- how to add year in drop down from past 2 year till present year in asp.net c#
- Gridview bind between two date from Database in ASP.NET C# Date format-dd/MM/yyyy
- Calculate Due and Advance amount in ASP.NET C#
- how to add year in drop down from past 2 year till present year in asp.net c#
- Bind Drop Down List With Month Name and Year without Database Using ASP.NET C#
- print div in javascript , print div content using jquery