Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is the detail of all my trouble.sorry i have already posted same type of Question but that one is not properly explained.
here is my page.cs code which is handling the alert message.
C#
  public virtual Literal MsgLitteral
    {
        get
        {
            return  (Literal)Master.FindControl("alert");
        }
    }

    protected virtual string ModuleName { get { return string.Empty; } }
if (MsgLitteral != null)
        {
            string isChecked = Session["isChecked"] == null ? string.Empty : Session["isChecked"].ToString();
            if (isChecked == "False" && Session["queryStatus"] != null && Session["notification"] != null)
            {
                MsgLitteral.ShowNotification(Session["notification"], Session["queryStatus"]);
                Session["isChecked"] = true;
            }
            else
            {
                MsgLitteral.Visible = false;
            }
        }


        base.OnLoad(e);
    }

    protected virtual void HandException(Exception ex)
    {
        if (MsgLitteral != null)
        {
            MsgLitteral.ShowNotification(ex.Message.ToString(), false);
        }
    }

    protected void Redirect(string url, string message = null)
    {
        if (string.IsNullOrEmpty(message))
            Session["notification"] = _queryStatus ? string.Format("{0} Saved Successfully", ModuleName)
                : string.Format("Error creating new {0}", ModuleName);
        else
            Session["notification"] = message;

        Session["queryStatus"] = _queryStatus;
        Session["isChecked"] = false;
        Response.Redirect(url);
    }

}
here is my site.master code where i call alert function in asp literal 
<pre lang="HTML"><form  runat="server" role="form">
                              

                                
                                     <script>
                                       {
                                             $('.date-picker').datepicker({ dateFormat: 'dd/mm/yyyy' });
                                             $('.search-select').select2();
                                             $('.time-picker').timepicker();
                                             $('.alert').delay(1000).fadeOut();
                                                                                         
                                         }
                                       Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                                   </script>

ASP.NET
<asp:UpdatePanel runat="server">
                                               <ContentTemplate>
                                                   <asp:Literal  runat="server" ID="alert" ></asp:Literal>
                                                   <asp:ContentPlaceHolder runat="server" ID="MainContent" ></asp:ContentPlaceHolder>
                                               </ContentTemplate>
                                           </asp:UpdatePanel>

Problem is that when data is inserted properly successful message is displayed. but when i clicked to make it disappear it does not appear nor fadeout.plz help me i am stuck in it for 2 days
Posted
Updated 2-Oct-14 13:52pm
v3
Comments
Trung Nguyen Son 2-Oct-14 21:21pm    
$('.alert').delay(1000).fadeOut(); => Where is your "alert" class?
Sajid227 3-Oct-14 5:46am    
i have that code at the end of master page,u mean to say that i have to write code just like this
<script>
jQuery(document).ready(function () {
Main.init();
FormElements.init();
$('.alert').delay(1000).fadeOut();

});
</script>
am i rite???plz help me out

1 solution

were is the element with alert being used as a css class name?? more important where is it in relation to where the script code is??

since you aren't wrapping that javascript in a function block this will run as the page is loading and if the element is after the script then it won't work.

this is why in jQuery you have:

JavaScript
$(document).ready(function(){
   // that want after the page is loaded goes in here...
})
 
Share this answer
 
Comments
Sajid227 3-Oct-14 5:46am    
i have that code at the end of master page,u mean to say that i have to write code just like this
<script>
jQuery(document).ready(function () {
Main.init();
FormElements.init();
$('.alert').delay(1000).fadeOut();

});
</script>
am i rite???plz help me out
Sajid227 3-Oct-14 6:01am    
i was wrong i was putting fadeout in the wrong place in master page,now i put itas describe above now it is function nicely,thanx bro +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900