Date format is not correct in the DataFormWebPart SharePoint 2010

Ok there is some problem when formatting date’s which is different than US format when using XsltListViewWebPart has defined by Microsoft. This happens because the ddwrt:FormatDate function expects the data format to be in UTC and the XSLTListViewWebPart returns the date preformatted to the Web Locale or Locale Date/Time .

To fixing this issue Microsoft has released a new feature ,A new Property, EnableOriginalValue, has been added to the XlstListViewWebPart that unblocks this scenario by February CU 2012.

You can check fallowing article for more information:
http://support.microsoft.com/kb/2580994

For DataFormWebPart;the option is to use the DataFormWebPart with the following property set to false on the <SPDataSource> tag: UseServerDataFormat.
Make UseServerDataFormat property set to false the DataFormWebPart will receive the Date/Time in UTC format and then the ddwrt:FormatDate function will work accurately.

Or you can use power of xslt to format date as you wish:
Fallowing example will help you to how to do it.

Add fallowing codes in DataFormWebPart for suitable place for xsl:template

<xsl:template name=”FormatCorrectDate”>
<xsl:param name=”dateValue” />
<xsl:param name=”monthFormat” />

<!– Sperater is important here it should be “.” or “/” according your current language settings –>
<xsl:variable name=”day” select=”substring-before($dateValue, ‘.’)” />
<xsl:variable name=”month” select=”substring(substring-after($dateValue, ‘.’), 1, 2)” />
<xsl:variable name=”year” select=”substring(substring-after(substring-after($dateValue, ‘.’), ‘.’), 1, 4)” />

<!– Create US Date Format –>
<xsl:variable name=”USDate”>
<xsl:value-of select=”$month” />/<xsl:value-of select=”$day” />/<xsl:value-of select=”$year” />
</xsl:variable>

<!– Month Notation –>
<xsl:variable name=”monthString”>
<xsl:choose>
<xsl:when test=”$monthFormat=’M1′”>
<xsl:value-of select=”$month” />
</xsl:when>

<xsl:when test=”$monthFormat=’M2′”>
<xsl:value-of select=”ddwrt:FormatDateTime(string($USDate), 1055, ‘MMM’)” />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select=”ddwrt:FormatDateTime(string($USDate), 1055, ‘MMMM’)” />
</xsl:otherwise>

</xsl:choose>
</xsl:variable>

<!– Create Date –>
<xsl:choose>
<xsl:when
test=”string-length($day) = 1″>0</xsl:when>
</xsl:choose>

<xsl:value-of select=”$day” />-<xsl:value-of select=”$monthString” />-<xsl:value-of select=”$year” />
</xsl:template>

Call formatting template where you can needed in code :

<xsl:call-template name=”FormatCorrectDate”>
<xsl:with-param name=”dateValue” select=”string(@Created)” />
<xsl:with-param name=”monthFormat”>M2</xsl:with-param>
</xsl:call-template>

Resources:
https://www.nothingbutsharepoint.com/sites/eusp/Pages/Bug-With-SharePoint-2010-XSLT-DateFormat-Function.aspx
http://social.msdn.microsoft.com/forums/en-US/sharepointcustomization/thread/7a636804-1ff1-4bb8-8bcd-9ef713d15680
http://support.microsoft.com/kb/2580994

Advertisements

About Sorting problem on Picture Library in Sharepoint 2010 after installing Dec 2011 CU

Hello Everyone,

We have a problem for sorting on Picture Libraries in Sharepoint 2010 . I have tested the issue SPS2010 + SP1 + Dec 2011 CU and can be easly reproducable.
The problem is when you click “Column” links or click popup window Ascending or Descending links nothing happens .Thats mean you can not able to sort items in Picture Libraries.
As far as i know it was working on SP1 level . The problem has occuring after CU upgrade.

Does any fix ? Not yet .(12/03/2012) I am expecting but not sure in June CU 2012 will fix the issue.
So until then you can use fallowing workaround to fix issue.

It is very simple wsp file created as site scope that dispatching postback events on picture libraries by using Jquery.
You can download WSP or Source project form Codeplex.
http://spssampleprojects.codeplex.com/releases/view/84054

For installing solution:

1) Download “PictureLibraryFix.wsp” file to c: drive of your sharepoint server

2) Open a Sharepoint Management Shell and

3) Type fallowing for adding solution to sharepoint
Add-SPSolution -LiteralPath c:\PictureLibraryFix.wsp

4)Type fallowing for installing solution:
Install-SPSolution -identity picturelibraryfix.wsp -GACDeployment

5)Type fallowing for enable feature on specific site collection:
Enable-SPFeature -Identity 8af7cb42-0fc7-4aa6-91e8-e1d1993b34cc -url http://blog.bugrapostaci.com

 

 

 

Sharepoint 2010 Character problem in Category Titles in Blog Site for different languages

Hello Everyone,

If you faced a character problem in Category Titles in Blog Site Template for different language , may be this article helps you. In my envoriment i am using Turkish Language Pack (1055) .
the repro is not tested on other languages but it  should be occurs for other languages which is contains specific characters .

I think this  problem is a minor bug .You can reproduce it easily .

Here the Repro steps.
1) Install or find SPS2010 + SP1Dec2011 CU + TR(1055) language pack installed machine.
2) Create a site collection in Turkish
3) Create a “Web Günlüğü”  (Blog Site Instance)
4) Add some categories that contains Turkish Characters.
5) Click one of this category titles in left navigation  and open category page

I have created a category named : “Yağlı Boya Seçmeleri”  You can see the problem bellowed screenshot.

The problem is when rendering left panel Categories web part (XSTLListView) not encode url of Link object correctly. I have tested with changing the link in browser’s address bar with correct encoding the titiles shown correctly on category page.

So There  is a workaround for fixing this issue with using Sharepoint Designer 2010 .

1) Open defauılt aspx and (any needed page) in Sharepoint Designer.

2) Select one of the link  in Categories  XsltListViewWebpart


3) Click the HyperLinkOptions button.

4) Change the default value of
{$HttpVDir}/{$thisNode/../@resource.wss.lists_Folder}/{$thisNode/../@resource.wss.blogcategories_Folder}/Category.aspx?CategoryId={$thisNode/@ID}&Name={$CategoryTitle} as
{$HttpVDir}/{$thisNode/../@resource.wss.lists_Folder}/{$thisNode/../@resource.wss.blogcategories_Folder}/Category.aspx?CategoryId={$thisNode/@ID}&Name={$thisNode/@Title}

5) Repeat same options for all needed pages.

And Open and Check  again your blog page :

(For who know Turkish the word of “Şeçme” have a little typo correct word is “Seçme” . Dont worry about it . i am not get all screenshot again for fixing this 🙂

See you next article.

c# Multiple WebRequest and WebResponse timeout problems.

Hi Everyone ,

In this tips and tricks article i wanna talk about when we use Multiple WebRequest object for interacting some urls getting timeout errors even if remote server not busy.
this is usually caused by not dispose some open WebResponse objects.You can also use “using” statement for disposing unnecessery objects .

For good example :

WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
// wrGETURL.Proxy = myProxy;

durationTime = DateTime.Now;

using
(HttpWebResponse response = (HttpWebResponse)wrGETURL.GetResponse())
{
status = response.StatusCode.ToString();
TimeSpan ts = DateTime.Now – durationTime;
duration = ts.TotalMilliseconds.ToString();
}

Solutions for InfoPath web service connection problems behind SSL enabled TMG or hardware Load Balancer in Sharepoint 2010

Hi Everyone,

In this article i will explain a well known problem about web service connection problem on your sharepoint servers behind SSL offload Load Balancer or TMG reverse proxy enabled topologies.

What is SSL Offload and Acceleration:
Depending on the workload, processing the encryption and authentication requirements of an SSL request can become a major part of the demand on the Web Server’s CPU and as the demand increases the users will see slower response times. To remove this demand from the Web Server a Load Balancer may be used to terminate the SSL at the Load Balancer. Some Load Balancer appliances include specialized hardware to process SSL. When a Load Balancer terminates the SSL connections the requests are converted from HTTPS to HTTP in the Load Balancer before being passed to the Web Server. So long as the Load Balancer itself is not overloaded this feature will not noticeably degrade the performance perceived by the end users.

For More information about Reverse proxy publishing: http://technet.microsoft.com/en-us/library/cc261814(office.12).aspx
So lets explain our topology. We have 2 WFE server and a Hardware Load Balancer.

WFE01 : Sharepoint Web Front End Server  which serving blog.bugrapostaci.com and our custom web service
/_layouts/CustomWebService/myservice.asmx
IP: 192.168.10.2

WFE02: Sharepoint Web Front End Server  which serving blog.bugrapostaci.com and our custom web service
/_layouts/CustomWebService/myservice.asmx
IP:192.168.10.3

HLB : Hardware load balacer device which is configured SSL Offload.

for this topology needed configuration fallowing Alternate Access Mappings …

Internal URL:  https://blog.bugrapostaci.com
Zone: Default
Public URL for zone:
https://blog.bugrapostaci.com  

Internal UR: http://blog.bugrapostaci.com  
Zone: Default
Public URL for zone: https://blog.bugrapostaci.com  

For more information about How do I configure a load balancer to accept only SSL requests please read fallowing article:
http://www.sharepointpromag.com/article/sharepoint/configure-a-load-balancer-to-accept-only-ssl-requests
Ok. If you establish your AAM correctly, you can able to browse our sharepoint site well. First of all all client computer in your domain must use HTTPS protocol for browsing
our portal even if they write http://blog.bugrapostaci.com it will redirected to SSL httpS://blog.bugrapostaci.com according AAM configuration. But on the server’s browsers i mean if you connect to WFE1 or WFE2 you can not browse the site with using SSL because there is not any SSL implementation configured on your sharepoint servers.(also this is which we want for performace) unless redirect to outside port of HLB which is mostly prohibited for security. So you can browse your portal using HTTP protocol only on WFE server’s browsers reversly client action.

Ok so far so good What is the problem ?
You have a developer machine outside of the server farm and can able to create Infopath Web Forms using Sharepoint Designer or Infopath 2010  .And they can publish their form to sharepoint and see all forms are working correctly by instead of SSL communication. But what if one of the InfoPath form needs to connect a web service which is already publishing on our sharepoint portal “/_layouts/CustomWebService/myservice.asmx” it can be built in sharepoint web service too but in this scenario is customized asmx file.

You will get the 5566 connection problem when you try to open this infopath form after publish to server.

Why ?
Because when you working with your infopath form in InfoPath2010 (in client machine) you can able to configure your web service connection with HTTPS.
For example https://blog.bugrapostaci.com/_layouts/CustomWebService/myservice.asmx
if you test form your client computer’s browser you can see WSDL without any problem.
yes on client machine you can able to reach this service without any error and develop your form as you want.But After you deploy/publish it to sharepoint server the form
(also publish ends successfully)  and assume that the user request this form ,wfe server process the pipeline and requests to connect webservice for getting data not the client !!! So as i told you before there is not any SSL connection can be done in server network but your published web service url is starting with https , and all requestes are redirected HTTPS according Alternate Access Mappings. You got the problem 🙂

So what we could do for resolving this issue

The first solution 

you can configure a rule for HLB (if it is configurable) that server request can over through directly load balancer by using https .mean you should allow the server requests pass through HLB even if requester machine itself. (But this time you may encounter with double-hop scenario).But somehow if you can not configure your LB or prohibited by security reson or faced with double hop  you need second solution which is a little complicated.

The Second Solution

1)  You can add another Host header to your site from IIS console which is using protocol of HTTP
http://myblogserviceDo not add any AAM record for it. If you create an AAM record it will rewrite your service url as https again.

2) Adding host file record of all request can be redirected to same machine (for preventing double hop)
For WFE1  ->   192.168.10.2    wfe1
For WFE2  ->  192.168.10.3    wfe2

3) Give only the developer machines to direct access http://myblogservice for able to create their infopath form correctly.

4) Enable Cross Domain options for InfoPath Services.
Central Administration –> General Application Settings –> InfoPath Forms Services –> Configure InfoPath Forms Services:
Note :If this is an administrator-approved form template, the security level of the form must be set to full trustAbout  InfoPath Security Model:
http://msdn.microsoft.com/en-us/library/bb251020(v=office.12).aspx

5) Create and use Data Connection Library for storing infopath connection information
How to: Create and Use a Data Connection Library
http://msdn.microsoft.com/en-us/library/ms772101.aspx

6) Configure your InfoPath forms as use connections udcx files. And use your new host header for connecting web service like
http://myblogservice/_Layouts/CustomWebService/myservice.asmx

7) And publish your forms.

If you completed all steps correctly, when a user browse an infopath form from your site one of wfe server handle the request by using https when the server need to connect
web service it will use http protocol which can be used by servers and you can able to browse your infopath for correctly without any connection error.

Sharepoint 2010 Scrollbar not working problem when hiding ribbon

Symptoms:

When using SPSecurityTrimmedControl for hiding Sharepoint 2010 ribbon scrollbar is not working for users who denied to see ribbon.

Cause:
If you use SPSecurityTrimmedControl cover all divs that include the ribbon in masterpage , the page is not renders correctly. This is an incorrect programming situation .

Incorret usage:

<SharePoint:SPSecurityTrimmedControl ID="IncorrectUsage" runat="server" PermissionsString="ManageWeb">
<div id="s4-ribbonrow" style="display:none">
<div id="s4-ribboncont">
   <SharePoint:SPRibbon...
    Your ribbon
   </Sharepoint:SRibbon>
</div>
</div>
</SharePoint:SPSecurityTrimmedControl>

Resolution:
Use your SPSecurityTrimmedControl inside of divs which is already covers ribbon.

Correct:

<div id="s4-ribbonrow" style="display:none">
<div id="s4-ribboncont">
<SharePoint:SPSecurityTrimmedControl ID="CorrectUsage" runat="server" PermissionsString="ManageWeb">
   <SharePoint:SPRibbon...
    Your ribbon
   </Sharepoint:SRibbon>
</SharePoint:SPSecurityTrimmedControl></div> </div>

..

For hiding ribbon correctly you need to add extra scripting .

First to be sure jquery added your master page .

<script type="text/javascript" src="http://blog.bugrapostaci.com/_catalogs/scripts/jquery.js"></script>

And we add an extra SPSecurityTrimmedControl which contains javascript for showing ribbon to who have to see.

<SharePoint:SPSecurityTrimmedControl ID="st1" runat="server" PermissionsString="ManageWeb">
this text will be shown by only admins
<script type="text/javascript">
$(document).ready(function()
{
$('#s4-ribbonrow').show();
});
</script>
</SharePoint:SPSecurityTrimmedControl>

and adding an extra attribute to cover div for hiding ribbon

<div id="s4-ribbonrow" style="display: none;">

Dont forget to save your master page and publish it.

If you dont want to attend too much you can download and use this tool for this.

http://spribbonvisibility.codeplex.com/

Happy solutions …
Bye now.
.