Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hi,

I am using Asp.net,VS2008.

How to display alert message from specfic time . just like alarm or reminder.

i have used this few code but message is not display on click .

------------------------------------------------
C#
/ displays an alert box with a specified message
    public static void Alert(string message)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(@"script language=JavaScript>");
        sb.Append(@"alert('" + message + "');");
        sb.Append(@"</");
        sb.Append(@"script>");

        ((System.Web.UI.Page)HttpContext.Current.Handler).RegisterStartupScript(new Guid().ToString(), sb.ToString());
    }

--------------------------------------------------
XML
public static class Alert
{

  /// <summary>
  /// Shows a client-side JavaScript alert in the browser.
  /// </summary>
   /// <param name="message">The message to appear in the alert.</param>
  public static void Show(string message)
  {
      // Cleans the message to allow single quotation marks
     string cleanMessage = message.Replace("'", "\\'");
     string script = "<script type=\"text/javascript\">alert('" + cleanMessage + "');</script>";

     // Gets the executing web page
      Page page = HttpContext.Current.CurrentHandler as Page;

        // Checks if the handler is a Page and that the script isn't allready on the Page
        if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
       {
          page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
       }
    }
}


please help me...
-------------------------------------------------------------------

Regards
Mukesh
Posted
Updated 23-Sep-13 2:24am
v3

You can use timer control and specify the interval in milli seconds for displaying modal window
 
Share this answer
 
Comments
mukesh_panth 23-Sep-13 7:34am    
how can display message box with current time using timer control in asp.net ....
 
Share this answer
 
use a timer control. In tick event of the Timer Control call the javascript function and show the alert.

Set the time in Timer control property.

-SG
 
Share this answer
 

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