use the below single line to show the error message in C# code behind in SharePoint.
ScriptManager.RegisterStartupScript(this, GetType(), “flash”, “alert(‘Error Message’);”, true);
The complete code will look like as this:
SPSite objSite = new SPSite(“http://sharepoint13:1245”); // I am trying to get the object of a site collection out side the FARM
ScriptManager.RegisterStartupScript(this, GetType(), “flash”, “alert(‘ You can not get the object out side this FARM’);”, true);
Note: In the above code block I am trying to get an object of a site collection out side the FARM.
Hope this helps, happy development in SharePoint !!!
Download FREE SharePoint 2019 Installation PDF Guide
This FREE PDF contains, Steps by step guide to install SharePoint 2019 Preview, prerequisites, hardware and software new features. First impression to SharePoint Server 2019 new modern site, modern lists and modern document libraries.
You May Also like the Following SharePoint Online Tutorials: