Populate cascading dropdown using JSON and jQuery…!

I got a requirement to populate two dropdowns with Country and Province/State data for a SharePoint 2007 project (data retrieved from SharePoint lists). So the first dropdown will contain the Country names. Second dropdown should populate details depending on the selected country on first dropdown. In my scenario, if the country is USA then populate the states from USA, and if its Canada, populate the provinces from Canada, if any other country keep the dropdown disabled.

I simple added two asp dropdown controls and bound data respectively of the first dropdown selected index change event. But the issue was for better user experience we had to avoid that post back.

Was reading about how to implement this and because of the reason, possible data for the province/state dropdown is small I went for a jQuery + JSON solution. I could have used a update panel and provided a Ajax solution. But with SharePoint 2007 integrating Ajax is a bit messy and also only because of dropdown data loading for it was a overhead doing that. Read more »

ECMAScript Client Object Model – Get the values from a multi select lookup column field

This post is another continuation of a series of posts related to ECMA Scripting and SharePoint client object model.

ECMAScript Client Object Model – Update a look up field

ECMAScript Client Object Model – Retrieve data from a list

So this time what I’m trying to achieve is to retrieve the values of a list item column. The column is a look up column that brings the data from another list, and the column is a multi select one. So the tricky part is how to iterate through all the lookup values in the specified list item.

Below is the complete ECMAScript for the list item retrieval and then iterating through every item and getting  the lookup values.
Read more »

ECMAScript Client Object Model – Update a look up field

In a previous post I discussed how to retrieve some values from a SharePoint list and bind it to a drop down list (HTML select). Later I had a requirement update back the selected value of the drop down to another separate list. The values I was retrieving was a lookup field in the second list I wanted to update.

My previous article on retrieve list data : Retrieve Data

So had to spend some time to properly understand how to do the look up field update using client object model.

I added a html button and wrote down a onclick event for the button.

<input type=”button” value=”Submit” onclick=”createListItem();” />

Below is the complete ECMAScript for the new list item update. It contains the two callback functions for successful item creation and failure of item creation. After a successful item creation, the new list item id will be displayed in a alert. Read more »

ECMAScript Client Object Model – Retrieve data from a list

I’m starting on SharePoint Online development. So was examining what are the capabilities of ECMAScripts and what we can really achieve. So started simply to read some values from a SharePoint list.

In the below example I’m trying to retrieve list data and populate them inside a drop down.

In the markup I have one Dropdown list that will get populated with the list data, and a button to trigger the event for retrieving data and populating the dropdown.

image

I have bound the retrieveListItems method to onclick event of the button.

<select id=”ddlCategory”></select> <br />

<input type=”button” value=”GetData” onclick=”retrieveListItems();” />

Then I have written my ECMA Script in a script block as bellow.

Read more »

Enable ECMA IntelliSense Sandboxed Visual WebPart…!!!

When working in Visual Studio we really a lot upon intelisense. Recently I started working on some SharePoint Online related work with ECMA Scripts and was finding very difficult to survive without VS intelisense.

There are many blog posts and articles  that illustrate how to enable intellisence in VS for ECMA Scripting. But most of them are not working with Sandboxed solutions and specifically with Sandboxed Visual Web Part (the template comes with SharePoint Power Tools)

So struggling for some time I was able to figure out how to enable it on Sandboxed Visual Web parts.

Steps:

1) Create the Sandboxed Visual Web Part from the VS Item template. Read more »

Cannot start service SPUserCodeV4 on computer…!!!

Recently I started testing out SharePoint Online solutions. Its really hard to develop a webpart and test and debug it on Online itself(Because you need to upload solution, activate manually again and again). So I am using my SharePoint server installation and deploying my custom development as sandboxed solutions and then debugging them. When the webpart looks good I go deploy it on SharePoint Online.

When I created my first sandbox solution and try to deploy through Visual Studio 2010 it prompted me with an error.

Error occurred in deployment step ‘Activate Features’: Cannot start service SPUserCodeV4 on computer ‘KAMILSP2010’.

So I figured out this is something to do with missing of a service that needed to deploy or run any sandboxed solution. Little bit of googling helped me to sort it out the issue.

To resolve this you need to navigate to
SharePoint Central Administration –> System Settings –> Manage services on server

then search for the service “Microsoft SharePoint Foundation Sandboxed Code Service“ and start the service.

image

Then tried the Visual Studio deployment again, all went fine. Smile

The Web application at ” could not be found…!!!

Today a friend was trying to build a console application that will retrieve some list data from a SharePoint site. He had created a console application, added needed SharePoint assembly references and wrote down the following code segment to access the Site Collection and then to retrieve the Web site.

static void Main(string[] args)
 {
     try
     {
         string siteURL = "http://mySite/";

         using (SPSite site = new SPSite(siteURL))
         {
             using (SPWeb web = site.OpenWeb())
             {

             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }

The code get compiled without errors, and when try to execute the line for creating a new SPSite from given site url, it throws and exception. The exception is:

The Web application at ‘http://mySite/’ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

We both were pulling hair to figure out what is going wrong. Doesn’t seem like anything wrong.

Later figured out the console application build Platform Target was set to x86. So after changing it to x64 it started working fine. Smile

Deploy Resource Files in SharePoint…

While doing SharePoint projects definitely you will have to use resource files to well mange and localize your resources. Not like an ASP.net application SharePoint requires you to deploy resource files to different locations.

To be clear, different operations will look the resource files in two different locations(Web parts refer one location and the resource entries in a feature manifest file looks in another etc…). The two resource locations SharePoint will look into are,

1) C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14Resources

2) The web application Virtual Directory (typically C:inetpubwwwrootwssVirtualDirectories {the web application port number}App_GlobalResources

So when we deploy a solution what typically done is coping the resource files to these locations manually.
 
How to overcome these manual steps?
Read more »

Show Hide Existing Ribbon Options / Commands…

Once I wanted to hide some ribbon options for a given permission set. Basically, in SharePoint 2010 the rich text content area allows to insert web part directly on it. I wanted to security trim so, only the users that has Contributor permission level or higher would be able to perform the web part insert.

While figuring out how to do this, I came across an option that, to create a new custom control to perform the show hide ribbon options.

1) Create a custom control (inheriting from System.Web.UI.Control)

2) Override the OnPreRender method

3) Retrieve the ribbon from the current viewing page.

SPRibbon ribbon = SPRibbon.GetCurrent(Page);

Read more »

Set Properties on a List View Web Part…

Hey buddies. Smile Ever wanted to set some properties on a List View Web Part? Had issues doing it? End up with no solution? Here you have the solution.

Recent past I had a requirement to create a page instance with a Calendar Month view embed in a web part zone. So my first thoughts was to create a page manually, add the required calendar View to it, set all custom properties (hide chrome is the only thing I had to do) and export. Oh Gosh, at the last step I realized you cannot export the Calendar View Sad smile.

Any how reading through the net I found a way to export the Calendar List View. But it contains some GUIDs that refers to the Default View of the calendar, that is created when the web part is provisioned and that I cannot predict before hand. Now what?

Read more »

« Older Entries Recent Entries »