Showing posts with label SharePoint Controls. Show all posts
Showing posts with label SharePoint Controls. Show all posts

Tuesday, March 31, 2015

Processing message for long code operations in SharePoint

As a SharePoint Developer you may need to show spinning wheel or Processing sign while lengthy code operations. You have probably seen this while creating new web application or site collection in Central Administration. You may need to show the processing messages for server side or client side long operation code. Showing processing message improves the user experience. SharePoint provides some nice ways to show processing message while long running code operations.

Server side code


On Server side, if you are executing some code that takes longer to process then you can use SPLongOperation Class to show processing request message. SPLongOperation would require redirecting the user to the destination page. Destination page could be same page or confirmation page. Following is the sample code to get the processing message for server side code:

Once long code is executed, you can end the operation by calling End() method. If you are calling SPLongOperation in modal popup then call EndScript() method to close the current dialog box. For example:


Client side code


For client side long operations, SharePoint provides following options to show wait screen dialog:

SP.UI.ModalDialog.showWaitScreenSize(title, message, callbackFunc, height, width) Method

Displays a wait/loading modal dialog with the specified title, message, height and width. Height and width are defined in pixels. Cancel button is shown. If user clicks it, the callbackFunc is called.

SP.UI.ModalDialog.showWaitScreenWithNoClose(title, message, height, width) Method

Displays a wait/loading modal dialog with the specified title, message, height and width. Height and width are defined in pixels. Cancel/close button is not shown.
Following is the code example to show the wait dialog on client side:

Monday, October 27, 2014

SPListItem Extension Methods To Get And Set Field Values

Followings are the extension methods for SPListItem class.

Single line of text, Multiline lines of text and Choice(Single)



Choice (Multiple)



Number, Currency



DateTime



Lookup (Single)



Lookup (Multiple)



Yes/No



User



User Collection



Hyperlink or Picture



Managed Metadata (Single)



Managed Metadata (Multiple)




You can download SPListItemExtensions.cs file containing all above extension methods.

Thursday, August 14, 2014

Snippets to create custom SharePoint forms/pages

Many times I create custom SharePoint forms in my solutions. More appropriate way is to create SharePoint form using InputFormSection. InputFormSection takes care of the layout and positioning of your controls. You can add InputFormControl containing asp.net/SharePoint controls under InputFormSection.

Add the following references in .aspx pages:


Container for InputFormSection:


Followings are some snippets of few common controls I use in custom SharePoint forms/pages:

Texbox








Multiline Textbox








Dropdown





Checkbox







Radio button








Url Field











File Upload









People Picker







Button




Tuesday, August 12, 2014

Sharepoint Selector Controls for custom administration pages

Sharepoint comes with four selector controls to choose destination elements for the operations.  These controls can be used in custom administration pages.  You can locate this controls under Microsoft.SharePoint.WebControls namespace.  To add selector controls you have include following page directive:



WebApplicationSelector

WebApplicationSelector control allow user to get or set the web application.




SiteAdministrationSelector

SiteAdministrationSelector control allow user to get or set the site collection.





WebAdministrationSelector

WebAdministartionSelector allow user to gets or sets the Web.  The web selector requires that SiteSelector not be a null reference.  So you have to use SiteAdministartionSelector to use this control.


ListAdministrationSelector

ListAdministrationSelector allow user to get or set the List or Document Library.  The List selector requires WebAdministartionSelector.  So if you want to use list selector then you have to use WebAdministartionSelector as well as SiteAdministrationSelector.





To get the selected values from above controls use CurrentItem property: