Translate

Thursday 15 November 2012

CheckForDuplicates confirmation message

protected void SaveButton_Click(object sender, EventArgs e)
{
    try
    {
        if (CheckForDuplicates())
        {
            //proceed normally
        }
    }
}

private bool CheckForDuplicates()
{
    //check database

            if (/*there are duplicates*/)
            {
                string message = "A duplicate name exists. Would you like to continue?";
                string scriptString = "<script language='javascript' 
                    type='text/javascript'>" + "return confirm('" + message + "');</script>";

                ScriptManager.RegisterStartupScript(this, this.GetType(), 
                    "script", scriptString, false);

                //here i would like to return their confirmation
            }
        }
    }
    return true;
}

No comments:

Post a Comment