Wednesday, February 29, 2012

Expected hex 0x in '{0xdddddddd, etc}

Sometime, developing a Sharepoint custom page with xslt view and selecting a row, results is this javascript error:

Expected hex 0x in '{0xdddddddd, etc}

Apparently there are some missing/malformed GUID into the xslt control.
Below the step necessary to resolve this issue:

1. Grab the guid of the AllItems.aspx page of the linked datasource list
2. Open the page and select the xslt view, add a new property named ViewGuid and set with the previous value
3. Change the value of the property Name of the XmlDefinition node with the previous value.

Side Effects:
If you have removed link for add new element this is restored.

Friday, February 24, 2012

Read Sharepoint Lookup field

Sharepoint stores the informations in Lookup fields this way:


Sometimes we need read just the value of id. Someone takes the field value as a string and split the content using Split or IndexOf. This technique is valid but..., if Microsoft changes the way the lookup information are saved ?

To read a lookup field you can use SPFieldLookupValue

Using SPFieldLookupValue we can split the values of the lookup field in a simpler way


Wednesday, February 22, 2012

Sharepoint ConnectionString from EventHandler

In some cases, developing a Sharepoint Event Handler, we needs to read the web.config; the code below solves the problem

This is the link to my Old Post

Query Sharepoint 2010 list via Javascript

Query Sharepoint 2010 list using JavaScript and Client ObjectModel

To read items from a Sharepoint list within a custom page you can use Javascript and client object model, below I explain necessary step to achive this.

Add a new page and reference the Object Model on the content of the page (Sp.js), I add also a reference to the jQuery library for the document ready event.

One very important thing is that you give the page time to load the object model javascript, to do this in the document ready function I call executeOrDelayUntilScriptLoaded that can wait for the fully loaded js.

The code I think is pretty clear: in the document ready I call executeOrDelayUntilScriptLoaded which waits for the loading of object model javascript, and after I calls the function getValues.

Function getValues create the sharepoint object model context and query the specified list for item with ID = 1. To the asynchronous function executeQueryAsync you must specify two callback: the first for the success, and the other for the errors.

If the call return without errors you must get values with the function get_item("ColName").

Thursday, February 9, 2012

ASP.NET strongly typed querystring parameters

To read strongly typed querystring parameters, I wrote a simple extension method that does the "dirty" job conversion
The use is simple:

Saturday, February 4, 2012

Open Sharepoint editing popup via javascript

In some cases, developing within sharepoint 2010, you need to launch through javascript a editing popup for an item. To achieve this functionality you must enter this code snippet:
The url passed to the function must be according to this scheme
Replacing <mysite>   with link to sharepoint site, or directly with
Replace <id> with the id of the element Enjoy!