Many times you need some customized functionality like Connect SharePoint contact list to outlook 2007.
I searched many sites but none helped me to find the perfect solution but the show me the way to achieve this.
Here is code for that how to modify inbuilt ‘Connect to outlook’ functionality in under webpart.
To implement this, write function in Creatchildcontrol method in web part.
//code here
Protected override void Creatchildcontrol ()
{
OutlookButton.Attributes.Add("onClick", "javaScript:OutlookContactSync('Contacts'
,'" + SPContext.Current.Web.Url + "', '/Lists/GeneralContact/'
, '" + SPContext.Current.Web.Lists["GeneralContact"].ID + "'
, 'GeneralContact'
, '" + SPContext.Current.Web.Title + "');");
}
Protected override void Render (HtmlTextWriter writer)
{
OutlookButton.RenderControl (writer);
writer. Write (javascriptpath);
}
Add the following JavaScript function that will be used to call the method you mentioned above.
//JavaScript function
function OutlookContactSync (type, baseUrl, listUrl, listId, listName, siteName)
{
var outlookURL = encodeURI ('stssync://sts/?ver=1.1&type='+type+'&cmd=add-folder&base-url='+baseUrl+'&list-url='+listUrl+'&guid={'+listId+'}&site-name='+siteName+'&list-name='+listName+'');
Var objWindow=window.open (outlookURL,'','width=0, height=0');
objWindow.close ();
}
If you have any questions you can reach out our SharePoint Consulting team here.
No comments:
Post a Comment