ASP.NET Javascript alert

You can use this C# function to call a Javascript alert:

private void ShowMessage(string msg)
{
  RegisterStartupScript (System.Guid.NewGuid().ToString(),
    string.Format("< script language='JavaScript'>alert('{0}');< /script>",
      msg);
}

1 Comment

michrosNovember 9th, 2006 at 2:08 am

Hello, this is quite good but it has a little error – I’ve tried to use it in ASP.NET 2.0 and it should be something like this:

private void ShowMessage(string message)
{
RegisterStartupScript (System.Guid.NewGuid().ToString(), string.Format(“alert(’{0}’);”,message)) ;
}

Leave a comment

Your comment