So I was intregued as to the actual answer as I have always left it in. I guess one of the reasons why is that I think its good practice and hasn't caused me any problems. This plus Visual Studio puts it in when you override the function.
However, it looks like you should leave it in as when reflected this is what's implemented underneath:-
public virtual ...
Pass around ClientContext.
Call .ExecuteQuery() as few times as possible, bundle/batch up with .Load().
Once is usually enough, only in a very few cases do you need more.
Do not pass around Web.
You need to reference other members from ClientContext, such as Site.
Do not pass around an URL (either as String or Uri).
Initialization method ...
But you can make such calls in SharePoint 2013:
var crossSiteContext = new SP.ClientContext("http://url-of-another-siteCollection/");
var crossSiteWeb = crossSiteContext.get_web();
Generally speaking you will want to use SPQuery to only query items you're interested in.
Unless you're doing
SPList oList = web.GetList("XYZ");
for(int i=0; i < oList.Items.Count; i++)
string strLstItemName = oList.Items[i].Name; // << BAD, as you use Items here, so you fetch them from DB each loop
there shouldn't be any relevant ...
AllowUnsafeUpdates=true; is not required to add/delete/update list items unless you are doing these operations in Page_Load or other Get methods. Both CASE 1 and CASE 2 does not look good in terms of best practice.
Problems with both case code:
Do not use oSPWeb.Lists["MyList"]; instead use oSPWeb.Lists.TryGetList("MyList1");
Do not use list.Items.Add(); ...
Yes its possible to have a single server SharePoint 2016 development Farm.
The machine needs to have atleast 16 GB RAM available. The processor should be 64 bit and 4 cores. Also there needs to be 80 GB space available for system drive and 100 GB for second drive.
Step by step guide - Single server 2016 installation & configuration
Install SP 2016
Any kind of hardcoded path is, in general, opposite from best practice so opening a SPWeb or SPList object directly from its full server URL is a no-no.
To get the SPWeb object, if you are sure your code will always run in your desired web it is perfectly okay to use SPContext.Current.Web. In all other cases, you might want to look at something like the ...
In the code behind the code may look like this:
var url = SPContext.Current.Web.Url + "/_layouts/myPage.aspx;
"CustomScript", "OpenDialog('" + url + "', 994, 1000, 'Title of the script', null);", true);
function OpenDialog(strPageURL, width,...
About your code: Since you are checking the value of an SPListItem in a different SPWeb but in the same SPSite, I think something like this will be better:
using (SPWeb web = properties.Site.OpenWeb("WebName"))
SPList list = web.GetList("/Path");
SPListItem item = list.GetItemById(theID);
From the MSDN article you posted:
Do not ...
It depends on the "context". In a web part or application page, use SPContext. A lot of example code you see on the web uses a console app for simplicity - these would use the SPSite constructor with a string parameter representing the url. In a Feature receiver you'd use (SPWeb)properties.Feature.Parent.
Bottom line is, if the code is being executed ...
As per my suggestion, Better to use field's internal name, in future if you may rename your field that doesnot affect the field which you updating on it. because field's internal name never change so no need to update code, whereas display name changed on rename field, so you need to update the code as per you define(renamed) field name
Objects like Web, ClientContext are passed by reference, that is they are not copied. So there is no need to worry about performance. However, as mentioned by @eirikb, pasing ClientContext between methods make more sense as you can then load whatever objects you want from it inside the method.
If you can whip up a console app and schedule it and it does the job - then great. I probably would rely on PowerShell. I prefer being able to monitor and alter scripts if needed without having to recompile or open up VS to make the edit. When working with data I've also used SSIS packages on SQL server.
If you are running SharePoint locally you have an ...
Here's our setup, if that can help you with ideas on getting your setup like you want it:
We use TFS for builds with the following setup:
Nightly build for DevTest
Manual triggered build for SystemTest. Depends on DevTest
Manual triggered build for UAT. Depends on SystemTest
Manual triggered build for Production. Depends on UAT
Depends here ...
Migration of controls developed using custom code has always been a problem, not when you migrate to newer versions but also when you move them to another server or on another farm.
The only reason "I KNOW OF or Experienced" Site Definitions create problems while migrating is because they can have different components in them, so when you deploy them to a ...
There are some, you can find these here:
For 2010: http://social.technet.microsoft.com/wiki/contents/articles/8666.sharepoint-2010-best-practices.aspx
For 2013: http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx
On this link, you can find a section called development which has some links about writing code.
The idea behind using one shared web application with host-named site collection is to overcome web application limitation of using multiple DNS name without having to extend the web application. By using host-named site collection, the DNS can now be set at site collection level and of course a site collection’s DNS name can be different from DNS of a Web ...
I don't see why you can't use the OOB versioning functionality.
If you enable versioning and content approval for your library and turn on major and minor versions, then whenever a document is submitted, it is marked as Draft and it gets assigned a minor version.
You can then use a standard approval workflow (or customize it to suit your needs) to approve ...
The New-SPContentDatabase cmdlet creates a new content database and attaches it to the specified Web application.
The Mount-SPContentDatabase cmdlet attaches an existing content database to the farm. If the database being mounted requires an upgrade, this cmdlet will cause the database to be upgraded.
so if you created database in advance, make sure the ...
TEMPDB is a temporary database that contains all Temporary user objects such as: global or local temporary tables, table variables, cursors. It also includes internal objects created by the SQL Server Database Engine; For example, work tables to store intermediate results for spools or sorting. All the mechanism of row versions is being handled and managed ...
You can order up your approaches as below,
I suggest, ULS - Its the SharePoint native logging and it manages to remove the older files periodically, its better to keep all the SharePoint related logs in one place "ULS". Use SPDiagnosticsService.Local.WriteTrace method in your timer job to log into the ULS logs
If you find that ...
I don't believe there is a difference in terms of what they return back (the string representation of the root URL of the site).
However, in the second case you are referencing both an SPSite and SPWeb object whereas in the first you are only referencing the SPSite object (so there might be some minor performance considerations if all you are looking for is ...
In your case you need to find whether the item exists or not, so there is no problem with invoking the CAML for each check.
Another approach is to form a dynamic query based on the number of rows to validate, for example if you want to validate 3 rows of data then form a query in with condition like