Sunday 28 February 2010

Windows Mobile reloaded!

http://www.engadget.com/2010/02/15/windows-phone-7-series-hands-on-and-impressions/
http://www.engadget.com/2010/02/15/windows-phone-7-series-is-official-and-microsoft-is-playing-to/
http://www.escapistmagazine.com/articles/view/columns/pocket-gamer/7196-The-Pocket-Gamer-Report-Android-and-Windows-Mobile-7

Thursday 25 February 2010

SharePoint Outlook Connector now works with SharePoint 2010

Finally I was able to make it working on SharePoint 2010. To be honest I did not have to do much things as most of the functionality worked pretty straightforward.

It also supports saving email meta data to SharePoint lists and attaching documents from SharePoint explorer panel.

Here is the link where you can download it.
http://spoutlookconnector.codeplex.com/

How to Add Current Item Field Values to DataFormWebPart as a parameter

How to Add Current Item Field Values to DataFormWebPart as a parameter

One of my colleague had to implement a page which should give master detail functionality. So the requirement was displaying related items in the display form page. So she placed two webparts one for current list item (master) and one for related items (details). As it was display form (DispForm.aspx) the only she had was ItemID which is in the querystring. But it was not enough, she wanted it to pass One of the current item field value to filter related Items List. There is no option in the DataFormWebPart to get that. Therefore she asked me if there is any workaround for this.

I did couple of investigation but could not find anything. Then I produced the following solution.

Basicly you place the following class into your project. That is a replacement for DataFormWebPart which allows you to set current Item Field Values as parameters.

* Deploy this class with your DLL into GAC
* Add this as a safe control into web.config
* Open your page do the following modifications

Place this to your page and change assembly, namespace with yours.

<%@ Register Tagprefix="ExWebPart" Namespace="Sobiens.SharePoint.WebParts" Assembly="Sobiens.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e76709a445fee1d6" %>

Goto DataFormWebPart tag and change it to <ExWebPart:EnhancedDataFormWebPart
Finally change your parameterbinding

<ParameterBinding Name="Country" Location="None" DefaultValue="currentitemvalue(Country)" />

This will set Parameter named Country to current item Country field's value.

Hope this helps.



public class EnhancedDataFormWebPart : DataFormWebPart
{
XmlDocument _ParameterBindingsXmlDocument = null;
XmlDocument ParameterBindingsXmlDocument
{
get
{
if (_ParameterBindingsXmlDocument == null)
{
_ParameterBindingsXmlDocument = new XmlDocument();
_ParameterBindingsXmlDocument.LoadXml("" + this.ParameterBindings + "");
}
return _ParameterBindingsXmlDocument;
}
}

XmlNode _ParameterBindingsXmlNode = null;
XmlNode ParameterBindingsXmlNode
{
get
{
if (_ParameterBindingsXmlNode == null)
{
_ParameterBindingsXmlNode = ParameterBindingsXmlDocument.SelectSingleNode("/ParameterBindings");
}
return _ParameterBindingsXmlNode;
}
}


private void SetParameterBinding(string key, string value)
{
XmlNode node = ParameterBindingsXmlNode.SelectSingleNode("/ParameterBindings/ParameterBinding[@Name = '" + key + "']");
if (node == null)
{
XmlNode parameterBindingNode = ParameterBindingsXmlDocument.CreateElement("ParameterBinding");

XmlAttribute nameAtrribute = ParameterBindingsXmlDocument.CreateAttribute("Name");
nameAtrribute.Value = key;
XmlAttribute locationAttribute = ParameterBindingsXmlDocument.CreateAttribute("Location");
locationAttribute.Value = "None";
XmlAttribute defaultValueAttribute = ParameterBindingsXmlDocument.CreateAttribute("DefaultValue");
defaultValueAttribute.Value = value;

parameterBindingNode.Attributes.Append(nameAtrribute);
parameterBindingNode.Attributes.Append(locationAttribute);
parameterBindingNode.Attributes.Append(defaultValueAttribute);

ParameterBindingsXmlNode.AppendChild(parameterBindingNode);
}
else
{
node.Attributes["DefaultValue"].Value = value;
}
}

private void ReplaceFormParameterBindings()
{
foreach (XmlNode node in ParameterBindingsXmlNode.ChildNodes)
{
string defaultValue=node.Attributes["DefaultValue"].Value;
if (defaultValue.ToLower().StartsWith("currentitemvalue(") == true)
{
int startIndex = defaultValue.IndexOf("(");
int lastIndex = defaultValue.IndexOf(")");
string fieldName = node.Attributes["DefaultValue"].Value.Substring(startIndex+1, lastIndex - startIndex-1);
if (SPContext.Current.Item[fieldName] != null)
{
node.Attributes["DefaultValue"].Value = SPContext.Current.Item[fieldName].ToString();
}
}
}
}

private void SetPropertiesAsParameterBindings()
{
ReplaceFormParameterBindings();
this.ParameterBindings = ParameterBindingsXmlNode.InnerXml;
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
SetPropertiesAsParameterBindings();
}
}

Tuesday 16 February 2010

FireFox's FireBug sometimes cause double postbacks

FireBug's double postback bug

"Thanks for the great responses here. In my case it turn out to be FireBug (version 1.05) with FireFox 2.0.0.20. Once I switched off the FireBug Add-in, the double posts stopped."

Monday 15 February 2010

SharePointOutlookConnector

SharePointOutlookConnector makes it easier for outlook users to upload emails to SP and attach SP documents to an email message . You'll no longer have to save your email to desktop and upload from SP UI or download SP documents to your drive and attach them to your email.

http://spoutlookconnector.codeplex.com/

Monday 1 February 2010

A GridView CommandField of type Image causes a double submit.

When clicking on a CommandField of type Image in a GridView, there are two submits. One is the onclick eventhandler and the other is the default submit of an input element of type image. In Beta2 and before there was no onclick event handler and so there was only one submit, this is only a problem since RTM.

http://connect.microsoft.com/VisualStudio/feedback/details/105123/a-gridview-commandfield-of-type-image-causes-a-double-submit