Hi Markperry,
If you want to give success and failure message then you can use below the code in button onClick event
try
{
XDocument.Save();
//Gives the success message
XDocument.UI.Alert("The form has been successfully saved");
}
catch(Exception ex)
{
//Gives the failure message
XDocument.UI.Alert(ex.Message);
}