[Solved] Remove (Unregister) ClientScript.RegisterClientScriptBlock in ASP.Net

zzchixo
 
on Mar 14, 2014 03:23 AM
12880 Views


Hi everyone,


How do i show the announcement - Please check the latest news!- on page load once. The user clicks on close button and it fades away. I do not want to show this annoucement everytime the page refreshes, just once when the user loads - the starting page (Default.aspx)

Thank you.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Mar 17, 2014 06:26 AM
on Mar 19, 2014 05:45 AM

There is no need to use Cookies here.

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        if (Session["info"] == null)
        {
            string message = "Information to display";
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + message + "');", true);
            Session["info"] = true;
        }
        else
        {
            //Remove the script
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "", false);
        }
    }
}