25 November 2005

ASP.NET Javascript alert

Posted by Mikhail Esteves under: C#; Tips .

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);
}
Technorati Tags , , , ,


One Comment so far...

michros Says:

9 November 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 Reply

Browse

Photography

Projects

Pages

Calendar

November 2005
M T W T F S S
« Oct   Dec »
 123456
78910111213
14151617181920
21222324252627
282930  

Categories

www.flickr.com

Use OpenDNS