Posts

Showing posts from 2013

Sharing a Page using JavaScript Object Model

Last week I was given a task to implement Share functionality using client side scripts. First I tried to search on the blogs but I didn’t find anything. So, I used IE developer tool to find out how SharePoint is calling Share from ribbon but no luck with it also. But I’m able to find the JavaScript function called on the click of “Shared With”. That is in Sharing.js that’s the main breakthrough. I opened the Sharing.debug.js to find out functions defined in that file. Then I find the function “ DisplaySharingDialog (webUrl, listId, listItemId) ” that is used to open the dialog box for sharing users. function SharePage(){ EnsureScriptFunc('sharing.js', 'DisplaySharingDialog', function () { DisplaySharingDialog(_spPageContextInfo.webAbsoluteUrl, _spPageContextInfo.pageListId, _spPageContextInfo.pageItemId.toString());                 }); } Since this function is defined in Sharing.js file that why we are trying to ensure that Sharing.js is already lo

Developing Apps for SharePoint 2013

App development in SharePoint 2013 is very cumbersome process using visual studio 2012. As in the process of developing my first testing App I’ve faced lot of issues, and after some goggling I was able to resolve those issues. So, here is the process we need to follow to develop and deploy App for SharePoint 2013: Configuring SharePoint 2013 to host Apps Setting-up App domain for hosting apps. Create the App management and Subscription Settings service application. Configure SharePoint to use App domain. For configuring these things you can follow the steps from this blog post . Developing and Deploying SharePoint-Hosted App For developing SharePoint-hosted app in visual studio you need Office Developer Tools for Visual Studio 2012 and the SharePoint Client Components . Once you have installed this tool you are ready to develop SharePoint-hosted Apps. Now follow the steps given in this blog post to develop an App. Note: Don’t use system account to deploy

Selecting all check box in a Table row or column

During one of my assignment I’ve come across a requirement to selecting all the checkboxes in a row or column of table. Accomplishing this task using server side code is really very difficult and need hard coding. So, I’ve come across idea of using jquery. Jquery is really very powerful, and it contains filters and selectors that we can use to select checkboxes. In the process of selecting checkboxes first step is to recognize whether user want to select row or column. So, I tried to get the parent of checkbox i.e. TH or TD. If it’s a TH then selecting column otherwise row. Case 1: Selecting row Selecting row is very simple, by this time you already have instance of TD then by using parent selected we can get the TR of that row.  And once we get TR then selecting checkboxes is piece of cake. Below is the code to select checkboxes. tr.find( 'input[type=checkbox]' ).attr( 'checked' , this .checked); Case 2: Selecting Columns Selecting column is little difficult t

Validating long form using jQuery

Programmer's are always wondering when it comes with validating long form with hundreds of controls. Most of the time programmers write code for saving and updating form values but validating is troublesome job for them and they often miss it or ignore is due to length of long form and too many controls. Checking validation manually using server side code is too troublesome. So, today I'm going to show you a simple jQuery for validating form. Since, it's a dynamic jQuery so you need not to worry about length of form and no. of controls on any form. Step 1: Place the following style on your page or stylesheet. span.required { color : Red ; font-size : 10px ; } span.number { color : Red ; font-size : 10px ; } span.date { color : Red ; font-size : 10px ; } span.emailid { color : Red ; font-size : 10px ; } Next step, a

SharePoint WebControls

In this post I’m going to tell you how to use SharePoint’s web controls in our custom code. It is very easy to use and it gives look and feel of SharePoint’s default forms. First we have to add the reference for Microsoft.SharePoint assembly and add using Microsoft.SharePoint.WebControls Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll) Namespace: Microsoft.SharePoint.WebControls SPWeb web = SPContext.Current.Web ; SPList list = web.Lists[ "ListName" ]; // Display Lookup field with Multiple selection enabled MultipleLookupField mlkpfield = new MultipleLookupField (); mlkpfield.ListId = list.ID; mlkpfield.FieldName = "MultiLookup" ; mlkpfield.ControlMode = SPControlMode .New; this .Controls.Add(mlkpfield); // Display List View Toolbar ViewToolBar toolbar = new ViewToolBar (); SPContext context = SPContext .GetContext( this .Context, list.DefaultView.ID, list.ID, SPContext .Current.Web); toolbar.RenderContext = con