Display expiry notification in Modal Popup after Login using jQuery in ASP.Net

Last Reply 2 months ago By pandeyism

Posted 2 months ago

Display flash popup meassages after login page

Enable Scheme expiry notifications before 3 days of expiry to person ad show the flash popup message using javascript.

 

You are viewing reply posted by: pandeyism 2 months ago.
Posted 2 months ago

Hi sathya2496,

Refer below code and accordingly to your database data check condition and open popup message.

HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript">
    function OpenModal() {
        $("#dialog").dialog({
            autoOpen: true,
            modal: true,
            title: "Expiring",
            buttons: {
                Ok: function () {
                    $(this).dialog('close');
                }
            }
        });
    }
</script>
<div id="dialog" style="display: none;">
    Your Product will expire in&nbsp;<span runat="server" id="date"></span>
</div>

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        // Database Datetime.
        DateTime dbDate = new DateTime(2019, 07, 23);
        if (dbDate.AddDays(3).ToString("dd/MM/yyyy HH:mm") == DateTime.Now.AddDays(1).ToString("dd/MM/yyyy HH:mm"))
        {
            date.InnerText = DateTime.Now.AddDays(1).Subtract(dbDate).Days + " days.";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "OpenModal();", true);
        }
    }
}

VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load
    If Not Me.IsPostBack Then
        ' Database Datetime.
        Dim dbDate As DateTime = New DateTime(2019, 07, 23)
        If dbDate.AddDays(3).ToString("dd/MM/yyyy HH:mm") = DateTime.Now.AddDays(1).ToString("dd/MM/yyyy HH:mm") Then
            date.InnerText = DateTime.Now.AddDays(1).Subtract(dbDate).Days & " days."
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "", "OpenModal();", True)
        End If
    End If
End Sub