Wednesday, 27 November 2019

Show alert error message when certain condition arises

I have the following code on page load that I use to show an error alert:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["message"] == "noemployees")
                    AlertDanger.Visible = true;

This is where the error is called. The page reloads and the error is shown.

if (payFitments == null)
{
     Response.Redirect("Default?message=noemployees");
}

I have the following markup

 <script type="text/javascript">       
        $(document).ready(function () {
            window.setTimeout(function () {
                $(".alert").fadeTo(1500, 0).slideUp(500, function () {
                    $(this).remove();
                });
            }, 3000);
        });
       -------------------------
<div runat="server" visible="false" id="AlertDanger" class="alert alert-danger">
        <a href="#" class="close" data-dismiss="alert">&times;</a>
        <strong>You must have at least one employee to process</strong>
    </div>

How do I show this message without having to load the default page again? Not seeing examples on the web that show this clearly.



from Show alert error message when certain condition arises

No comments:

Post a Comment