-----------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>");
}
}
No comments:
Post a Comment