Get confirmation from user????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I am writing a page that requires a decision from the user, e.g. when the user clicks delete I need a message box to popup and ask the user for confirmation Depending on the users response will depend on whether the ASP.Net delete function is called. I am able to register a Client-side script enough to show a msgbox, but only with an okOnly button, and even if I got a YesNo button to display, is there any way to inject that decision into my ASP.NET code?

This is really causing me a headache so any help with this would be greatly appreciated

Thanks

Karl
 
Karl,

Add the following code to your app in the Page_Load for instance .. :

btnDelete.Attributes.Add("onclick", "return (confirm("Delete this item
?")==true) ;")

Kind regards,

Jurjen de Groot,
Netherlands



Karl said:
Hi all,

I am writing a page that requires a decision from the user, e.g. when the
user clicks delete I need a message box to popup and ask the user for
confirmation Depending on the users response will depend on whether the
ASP.Net delete function is called. I am able to register a Client-side
script enough to show a msgbox, but only with an okOnly button, and even if
I got a YesNo button to display, is there any way to inject that decision
into my ASP.NET code?
 
/// <summary>
/// Adds a JavaScript "alert()" with strMessage to Page Startup
/// </summary>
/// <param name="strMessage">Message to display</param>
public static void MsgBox(string strMessage)
{
StringBuilder s;
System.Web.UI.Page p;
if (HttpContext.Current == null) return;
s = new StringBuilder("<script type=\"text/javascript\">" +
Environment.NewLine +
"<!--" + Environment.NewLine);
s.Append("alert('" + strMessage.Replace("\"", "\\\"") + "');" +
Environment.NewLine + "// --></script>");
p = (System.Web.UI.Page) HttpContext.Current.Handler;
if (!(p.IsStartupScriptRegistered("MsgBox")))
p.RegisterStartupScript("MsgBox", s.ToString());
}

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

bassil said:
Yes , You can try this one :

MessageBox for ASP.NET from http://www.bassilsoft.com

There is a samples in the package could meet your need. Please download it
to see the source code.
 
Back
Top