Posts

SharePoint Interview Questions and Answers

Q. What does AllowUnsafeUpdates do ? Ans. If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property. C#: ? 1 2 3 4 5 6 7 8 9 10 using(SPSite mySite = new SPSite("yourserver")) { using(SPWeb myWeb = mySite.OpenWeb()) { myWeb.AllowUnsafeUpdates = true; SPList interviewList = myWeb.Lists["listtoinsert"]; SPListItem newItem = interviewList.Items.Add(); newItem["interview"] = "interview"; newItem.Update(); } } Q What does RunWithElevatedPrivileges do? Ans. Assume that you have a Web Part in which you want to display information obtained through the Windows SharePoint Services object model, such as the name of the current site collection owner, usage statistics, or auditing information. These are examp

C# Coding Standards - and Naming Conventions

C# Coding Standards - and Naming Conventions   Why : consistent with the Microsoft's .NET Framework and easy to read.   use PascalCasing for class names and method names.   public class ClientActivity {      public void ClearStatistics()     {          //...     }      public void CalculateStatistics()     {          //...     } } use camelCasing for method arguments and local variables public class UserLog {      public void Add( LogEvent logEvent)     {          int itemCount = logEvent.Items.Count;          // ...     } }    Do not use Hungarian notation or any other type identification in identifiers // Correct int counter; string name;   // Avoid int iCounter; string strName;   Why : consistent with the Microsoft's .NET Framework and Visual Studio IDE makes determining types very easy (via tooltips). In general you want to avoid type indicators in any identifier.   Do not use Screaming Caps for constants or readonly variables // Correct public static