Maybe someone somewhere had the same issue and can help me out. I'm using the DateTimeControl in a User Control (markup) which in turn is used on a page that is part of a SharePoint solution.
On some environments, the DateTimeControl styling appears broken. However, using the default site and the tasks list, the same control's styling works fine.
Checking the HTML output of the page on the afflicted environment, it seems like the CSS stylesheet is not linked to the page. I checked the direc开发者_StackOverflow中文版tories and the files do exist.
[Edit - More info]
The date picker popup calendar appears inside an iframe, typically referenced like so:
_layouts/iframe.aspx?&cal=1&lcid=1033&langid=1033&ww=0111110&fdow=0&fwoy=0&hj=0&swn=False&minjday=109207&maxjday=2666269&date=11%2F22%2F2010
The markup of the actual file looks like so:
<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages" %> <%@ Page Language="C#" Inherits="Microsoft.SharePoint.ApplicationPages.DatePickerFrame" %> <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <% SPSite spServer = SPControl.GetContextSite(Context); SPWeb spWeb = SPControl.GetContextWeb(Context); %>
<html dir="<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,multipages_direction_dir_value%>' EncodeMethod='HtmlEncode'/>">
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<SharePoint:CssLink runat="server"/>
<script type="text/javascript" src="./DatePicker.js"></script>
<title>Date Picker</title>
</head>
<body onload="PositionFrame('DatePickerDiv');" onkeydown="OnKeyDown(event);" style="margin:0;">
<SharePoint:SPDatePickerControl id="DatePickerWebCustomControl" runat="server" >
</SharePoint:SPDatePickerControl>
</body>
</html>
The correct output will include a head section similar to this:
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/datepickerv4.css?rev=Hu9OlQmu1YOXv7TK%2BQrc5Q%3D%3D"/>
<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css?rev=iIikGkMuXBs8CWzKDAyjsQ%3D%3D"/>
<script type="text/javascript" src="./DatePicker.js"></script>
<title>Date Picker</title>
</head>
Notice the link to the datepickerv4.css stylesheet? However, it has happened on some environments, that the head section in the HTML output, looks like so:
<head>
<meta name="GENERATOR" content="Microsoft SharePoint" />
<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css?rev=iIikGkMuXBs8CWzKDAyjsQ%3D%3D"/>
<script type="text/javascript" src="./DatePicker.js"></script>
<title>Date Picker</title>
</head>
Notice the missing link? I have tried repairing the installation of SharePoint but alas. I have used the DateTimeControl.ApplyStyleSheetSkin method without success.
It must be something that I need to do, because the DateTimeControl on task lists behave correctly on the affected environments.
Any ideas
The problem was with managed paths, here follows the scenario:
A managed path ('manage') was created. On the managed path, a team site was created. A blank site was created on 'manage' named 'blanksite' and within it another site named 'portal'.
The path used for the iframe calender page should have been http://host:port/manage/blanksite/portal/_layouts/iframe.aspx but instead only read as http://host:port/_layouts/iframe.aspx.
Although accessible, the context was incorrect, which meant that the DatePicker's CSS was never attached.
To remedy the problem, we have set the DatePickerFrameUrl property of the DateTimeControl elements inside the user control to 'SPContext.Current.Web.ServerRelativeUrl + "/_layouts/iframe.aspx"'.
Setting the DatePickerFrameUrl
property of the DateTimeControl
element inside the user control to SPContext.Current.Web.ServerRelativeUrl + "/_layouts/iframe.aspx"
fixed my issue.
How are you referencing the CSS style sheet? Is it via a master page or a direct reference in your user control? If the latter, it could be it's not quite pointing to the correct location. Have you tried the Web Developer plugin for Firefox, and Firebug, to verify the style sheet is being picked up correctly?
精彩评论