Hello,
I have an ASP web application and in the C# code behind I want to present the user with a simple yes/no dialog box that gives them the opportunity to save a file that their input has created.
I've used a simple implementation of ClientScript.RegisterStartupScript elsewhere in the code to display simple messages, but I'm having trouble getting a yes/no type dialog to appear. I'm using this code:

      try
      {
        ClientScript.RegisterStartupScript(this.GetType(), "Msg", "<script type=\"text/javascript\"  language=\"javascript\">function showMsg(){return confirm(\"Do you want to save the WH XML file created?\");}</script>", true);
      }

But the dialog never appears. Can someone suggest where my mistake is?

Try this

 try
 {
    ClientScript.RegisterStartupScript(this.GetType(), 
        "Msg", 
        "return confirm('Do you want to save the WH XML file created?');",
        true);
}

Still no dialog box appears. The code is traversed, but nothing happens...
Thanks

ClientScript.RegisterStartupScript(GetType(), "messagebox", "<script language='javascript' type='text/javascript'>confirm('Do you want to save the WH XML file created?');</script>");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.