You Can use the below method to show the alert message
public static void ShowAlertMessage (String error)
{
Page page =HttpContext.Current.Handler as Page;
if(page!=null)
{
error=error.Replace("'","\'");
ScriptManager.RegisterStartupScript(page, page.GetType(),"err_msg","alert('"+error+"');",true);
}
}