Thursday, October 6, 2011

How to filter the data in data form web part using calender control


ParameterBinding Name="PFromDate" Location="Control(CalFrom,SelectedDate)" DefaultValue=""
ParameterBinding Name="PToDate" Location="Control(CalTo,SelectedDate)" DefaultValue=""


Convert the date into number (YYYYMMDD)

number(string(ddwrt:FormatDateTime(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date),1033,1)),'/','-'),1060,'yyyyMMdd'))) >= number(string(ddwrt:FormatDateTime(translate(string(ddwrt:FormatDate(string($PFromDate),1033,1)),'/','-'),1060,'yyyyMMdd'))) and number(string(ddwrt:FormatDateTime(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date),1033,1)),'/','-'),1060,'yyyyMMdd'))) <= number(string(ddwrt:FormatDateTime(translate(string(ddwrt:FormatDate(string($PToDate),1033,1)),'/','-'),1060,'yyyyMMdd')))

old: Wrong Calc
number(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1)),'/','')) >= number(translate(string(ddwrt:FormatDate(string($PFromDate), 1033, 1)),'/','')) and number(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1)),'/','')) <= number(translate(string(ddwrt:FormatDate(string($PToDate), 1033, 1)),'/',''))
new


Ref:


number(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1)),'/','')) = number(translate(string(ddwrt:FormatDate(string($PFromDate), 1033, 1)),'/',''))

ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1) >= ddwrt:FormatDate(string($PFromDate), 1033, 1) and ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1) <= ddwrt:FormatDate(string($PToDate), 1033, 1)


number(translate(string(ddwrt:FormatDate(string(@Report_x0020_Date), 1033, 1)),"/",""))

number(translate(string(ddwrt:FormatDate(string($PFromDate), 1033, 1)),'/',''))

Wednesday, October 5, 2011

How to disable the RichTextBox in SharePoint

function disableRichTextBox(ctrlComments)
{
ctrlComments.disabled=true;
ctrlComments.readOnly=true;
var elm = document.getElementById(ctrlComments.id + "_toolbar");
if (elm) {elm.disabled=true; elm.readOnly = true;elm.style.display = 'none';}
elm = document.getElementById(ctrlComments.id + "_iframe");
if (elm) {elm.disabled=true; elm.readOnly = true;elm.style.display = 'none';}
ctrlComments.style.display = 'block';
}

Wednesday, August 31, 2011

SharePoint 2010 Ribbon Customization

http://makarandrkulkarni.blogspot.com/2010/01/sharepoint-2010-ribbon-customization_23.html

Monday, August 1, 2011

New SharePoint 2010 content for download

http://www.wssdemo.com/Blog/archive/2009/10/19/new-sharepoint-2010-content-for-download.aspx

Friday, March 25, 2011

Hide List View Tool bar Items

function hideListViewToolbarItems()
{
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
var itm = doc[i];
if (itm.id.match('OpenInExplorer') != null)
{
var p = itm.parentNode;
p.removeChild(itm);
}

}
}

A few thoughts as to why it's not working...

1) Match for part of the text and leave off the "zz33_" as that part can be different for every page.

2) Don't delete the nodes, hide them

3) Make sure your code is loaded after the web part with the View dropdown (i.e. if using a Content Editor Web Part, move it under the list web part)

Reference:MSDN

Thursday, March 24, 2011

Add Web Parts to DispForm, EditForm or NewForm.aspx

One of the users of our SharePoint project asked if it was possible to show an “Item List” on the “View Item” page.

My first reaction was: “Of course it is, add a Web Part displaying the “Item List” to the page and we’re done”.

But when I browsed to the “View Item” page and clicked the “Site Actions” I noticed that there wasn’t an “Edit Page” option available. Strange, but after some -Googling- I found the following sollution:

  • Open IExplorer and navigate to your “View Item” page (DispForm.aspx)
  • Replace everything in the URL after “?ID=#“ with “&PageView=Shared&ToolPaneView=2″ (without the quotes of course) and press
After adding a Web Part to the page and saving it, the “Edit Page” option will be available the next time you click “Site Actions” on that Page.

Document library Views Dropdown to change the View disappeared

When you go to a document library or list in Sharepoint 2007, you see a dropdown in which you can select a different view or create a new view if you have the right permissions.

If you ever find yourself thinking “Where did the change the view dropdown go?”

Change view disappeared

Don’t worry, one of two things could have happened.

  1. You added a second document library webpart on your page, but this would be obvious because you would see two webparts, one with a dropdown and one without it.
  2. Your user (or yourself) -closed- the webpart and added it again, leaving the closed webpart on the page, but hidden. This one is harder to detect, because you only see the webpart without the dropdown.

Close webpart

How do you fix this?

In the first case there isn’t much of a problem, you -delete- the second webpart from the page or you leave it on there (but without the dropdown).

For the second case you’ll have to edit the page (Site Actions, Edit Page), press Add a Web Part. At the bottom of the dialog is a link “Advanced Web Part gallery and options“, click it. A side bar “Add Web Parts” appears. Below the “Select the collection you want to browse.” is a link called “Closed Web Parts“, when you click it the Web Part List with closed Web Parts appears. Select the Document Library Web Part and click the “Add” button on the bottom of the screen. The page will show the two Web Parts, -delete- the one without the dropdown and you’re back in business.

Why? A web part which shows a list is supposed to display only one view of the list at a time. But you can definitely change the view by modifying the shared web part properties.

Useful Parameters to date for WSS 3.0 and MOSS 2007

Back in the days of WSS v2 and SPS 2003, one could use some handy URL parameter passing to edit web pages and browse for or search web parts.

My three favorite parameters for WSS v2 and SPS2003 were:

To Correct or Remove Misbehaving Web Parts
http://server/default.aspx?Contents=1

To Open the Page in Web Part Design Mode
http://server/default.aspx?ToolPaneView=2

To Open the Search Web Part Zone
http://server/default.aspx?ToolPaneView=3

Now in WSS 3.0 and MOSS 2007 we have the much more practical approach of switching views. Enter the Site Actions Menu, using the menu options we can edit the page, browse to site settings, etc.. But what happens if the Site Actions menu is not visible on the page. Maybe it was missed in the look and feel or has been removed deliberately like I had to do recently for a client. Now why someone would need to remove it and how this can be achieved (in at least two ways) will be covered in a later post.

Here are my favorite parameters to date for WSS 3.0 and MOSS 2007:

To open the Design Bar - Useful for pages in the Pages Library
http://server/default.aspx?DisplayMode=Design

To turn on Web Part Zone Editing
http://server/default.aspx?ControlMode=Edit

Note: The Site Actions Menu is rights trimmed and that means not all users can see or use it. Users with limited access or read rights will not be able to make use of the URL\Query String parameters. The parameters are just an alternative to get to the editing\design controls rather then a security bypass.

Wednesday, February 23, 2011

how to do web part connections in SharePoint 2010

1) Add web part zones to that page
2) Add my custom web parts in that zones
3) Connect those web parts in the page itself.


When I created the web part using Visual Studio 2010 template, it got derived from System.Web.UI.WebControls.WebParts namespace,

I changed that to Microsoft.SharePoint.WebPartPages.WebPart which solved my problem.

Monday, January 31, 2011

Delete event receiver from a SharePoint list

  1. private void DeleteEventReceiverFromAList(string siteUrl)
  2. {
  3. using (SPSite site = new SPSite(siteUrl))
  4. {
  5. using(SPWeb web = site.OpenWeb())
  6. {
  7. try
  8. {
  9. SPList list = web.Lists["myList"];
  10. if (list != null)
  11. {
  12. string className = "EventReceiverClass";
  13. string asmName = "EventReceiverAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a865f0ecc234ea51";
  14. web.AllowUnsafeUpdates = true;
  15. int receivers = list.EventReceivers.Count;
  16. bool isAddedReceiverExist = false;
  17. bool isUpdatedReceiverExist = false;
  18. for (int i = 0; i <>
  19. {
  20. SPEventReceiverDefinition eventReceiver = list.EventReceivers[i];
  21. if (eventReceiver.Class == className && eventReceiver.Type == SPEventReceiverType.ItemAdded)
  22. {
  23. eventReceiver.Delete();
  24. break;
  25. }
  26. }
  27. }
  28. }
  29. catch { }
  30. finally
  31. {
  32. web.AllowUnsafeUpdates = false;
  33. }
  34. }
  35. }
  36. }