Search This Blog

Thursday, April 29, 2010

Automatic Redirection to the Data Form Web Part page on Close / Save / Cancel

In SharePoint - We know that if Source parameter is used in the QueryString in browser, the page is redirected back to the URL specified in Source querystring parameter.

While creating Data Form Web Part we need this functionality.

Examples:
a) A link to create a new item in a list is specified in DFWP. When the user saves or cancels on the new page, it should be redirected back to the original page where this new link was specified
b) Links to a list item display page. After visiting the page, when user clicks Close on the page, again it should be redirected to the page from where the link was clicked on.

Since the DFWP can be on any page we want it to be generic so that on whichever page DFWP is placed i.e. say page X , after the destination page is visited and "close / cancel / ok" is clicked it should come back to page X.

Here is how to do it:
First create two parameters in DFWP as shown in the images below. These pick up values from Server Variables of IIS Server.





Now in DFWP where you specified a URL append this:

Source=<xsl:value-of select="$MyURL"></xsl:value-of>?<xsl:value-of select="$QS"></xsl:value-of>

(You also need to encode the strings)

and now when users click from the link specified in the URL and they hit close / cancel / save they
are redirected back to the page in Source querystring parameter.

This is what I have used in the past and now.

Have you used any other method for this? If yes - am interested to know.

-- Mohan

Tuesday, April 27, 2010

Display Today and Tomorrow events from a Calendar - using CAML

Here is the CAML
<Or>


<Eq>

<FieldRef Name="EventDate" />

<Value Type="DateTime">

<Today />

</Value>

</Eq>

<Eq>

<FieldRef Name="EventDate" />

<Value Type="DateTime">

<Today OffsetDays="1" />

</Value>

</Eq>

</Or>

The important part of this CAML is the OffsetDays keyword that allows to get future or past dates relative to Today. For example: Data for past 2 days would be OffSetDays="-2"

Well this one is a very well known formula, however I want to write this in my blog for quick syntax reference.

SharePoint Designer 2007: Page Processing error

On browsing the page layout from IE:

An error occurred during the processing of /_catalogs/masterpage/.aspx. Only Content controls are allowed directly in a content page that contains Content controls.

This means the Page Layout has possible tags above the Page tag.

Remove those tags (example: HTML, Head etc including the closing tags) and the error is gone....

Saturday, April 17, 2010

New properties in Web Part configuration

Well as you can see from the above screenshot there are 2 new sections  i.e. AJAX options and Miscellaneous. AJAX options are obvious. You could configure AJAX Load / Update / Refresh manually and refresh data automatically after predetermined # of seconds. If you want to display your own format for the List data - use XSLT in the XSL link from miscellaneous section.