Wednesday 1 June 2011

Adding New Discussion and replying to the Discussion Item using Object Model

New Discussion:
SPListItem oListItem =SPUtility.CreateNewDiscussion(oList.Items, TitleField.Text);
oListItem[SPBuiltInFieldId.Body] = MessageBox.Text;
         oListItem.Update();
 Discussion reply:
SPListItem parent = list.GetItemById(parentId);
         SPListItem reply = SPUtility.CreateNewDiscussionReply(parent);
reply[SPBuiltInFieldId.Body] = body;
                  reply.Update();

Virto Bulk Upload

Ø  Site gets updated with Virto Bulk File Upload Web Part for SharePoint 2010, Ribbon Item for the lists to Attach Multiple Files and ECB Action Item for the lists to Attach Multiple Files.

Ø  From the web part properties we can choose the any choose the site and then Bulk Upload or Attach Multiple Files.

Ø  If we choose Bulk Upload we get an option to choose single document library for uploading multiple files.

Ø  If we choose Attach Multiple Files we get an option to choose List and single list Item for attaching multiple files to the selected list item.

Ø  If we have any required fields it gives an alert.

Ø  We can edit the metadata for single item or for all the items at a time

 

Drawbacks:

Ø  At a time we cannot upload to 2 document libraries. Every time we should change the web part properties for uploading into different list/library

Ø  If we have any Managed Meta Data field type as column as required field, this field is not showing in the Properties screen. As it is a required field we are not able to upload single item to that library.

Ø  Under Web Part properties it has an option to enter Redirect Url. I didn’t find any use of this value.

Ø  After uploading it will not show any message like uploaded successfully.

Delegate Control

The Delegate Controls comes into picture when want to brand a SharePoint Site. The delegate control acts like a container control which encapsulates default content (set of child controls inside it). The default content (set of child controls associated with delegate) can be substituted by a specific control, by creating a feature. The ability to override or substitute the delegate controls brings the power & flexibility to brand SharePoint Sites.

The out-of-box SharePoint Foundation Master Page defines many controls like Top Navigation Data Source, Left Navigation Data Source, Search Box and Additional Page Head etc as delegate controls. The list is illustrated below :-
<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
<SharePoint:DelegateControl runat="server" ControlId="GlobalNavigation" />
<SharePoint:DelegateControl runat="server" ID="GlobalDelegate0" ControlId="GlobalSiteLink0" />
<SharePoint:DelegateControl ControlId="GlobalSiteLink2" ID="GlobalDelegate2" Scope="Farm" runat="server" />
<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Id="PublishingConsoleDelegate" />
<SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server" />
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4" />
<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate"/>
The above listed delegate controls can be substituted at runtime to achieve custom branding. Or else we can create our own delegate and we can add to our master page.
<SharePoint:DelegateControl ControlId="TimeZoneDelegate" runat="server"/>

Steps to create DelegateControl:
  1. File -> New Project -> SharePoint Empty Project.
  2. Add New Class and change its base class to System.Web.UI.WebControls.WebControl
  3. Override required methods like OnLoad,CreateChildControls or Render.
  4. Add New Module with Elements.xml and add the below tag. add the safe control entry as well.
    <Control Id="TimeZoneDelegate"  Sequence="100" ControlClass="addedclassFullName" ControlAssembly="$SharePoint.Project.AssemblyFullName$"  ></Control>
  5. Instead of adding a class we can use an UserControl and refer it in ControlSrc property of Control tag in place of ControlClass and ControlAssembly.
  6. Deploy the feature.