Wednesday, October 12, 2011

Createing a alert Class in asp.net

                                  /*AlertBoxes.cs*/

using System.Web;
using System.Web.UI;

/// <summary>
/// Summary description for AlertBoxes
/// </summary>

namespace alert
{
    public class AlertBoxes
    {
        public static void ShowAlertMessage(string error)
        {
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                error = error.Replace("'", "\'");
                ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + error + "');", true);
            }
        }
    }
}




/*use like this*/
                alert.AlertBoxes.ShowAlertMessage("alert");

No comments:

Post a Comment