Write this code at server side where you want to display confirmation box 
Server side Confirmation code :
    var sbk = new StringBuilder();
                        sbk.AppendFormat("var foo = window.confirm('Data Already Exists.Do you want to replace?');\n");
                        sbk.Append("if (foo)\n");
                        sbk.Append("__doPostBack('MyConfirmationPostBackEventTarget', foo);\n");
                        ClientScript.RegisterStartupScript(GetType(), "MyScriptKey", sbk.ToString(), true);
                        ClientScript.GetPostBackEventReference(this, string.Empty);
In page load write this code 
 ClientScript.GetPostBackEventReference(this, string.Empty);
        if (IsPostBack)
        {
            string eventTarget = Request["__EVENTTARGET"] ?? string.Empty;
            string eventArgument = Request["__EVENTARGUMENT"] ?? string.Empty;
            switch (eventTarget)
            {
                case "MyConfirmationPostBackEventTarget":
                    if (Convert.ToBoolean(eventArgument))
                    {
                        AfterUserConfirmationHandler(tablename);
                    }
                    break;
            }
        }
 
 
No comments:
Post a Comment