Wednesday, March 24, 2010
SharePoint jQuery: Setting View Column Width
With jQuery there is no need to use SPD or to convert the view. In the following example jQuery will change the width of the two columns "Status description" and "Type of Work" by changing their CSS style attribute.
Start by looking up the HTML markup for the two table headers using View-Source. I'm using jQuery filters that look for the TH elements using a CSS class selector and a content filter. Then add a Content Editor web-part (CEWP) to your page and enter this script in the source editor:
<!--ADJUST TABLE COLUMN WIDTH-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("TH.ms-vh2-nograd:contains('Status description')").css("width", "150px");
$("TH.ms-vb:contains('Type of Work')").css("width", "150px");
});
</script>
Tuesday, March 23, 2010
This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application
Scenario:
You scoped your solution to WebApplication and trying to deploy the solution to a particular Web Application
Error:
This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application.
OR
This solution contains no resources scoped for a Web application and cannot be retracted from a particular Web application.
Reason:
Its because of the parameters passed to STSADM , basically features included in the solution does not contain an assembly which can be scoped to a particular Web Application. What ever assemblies are part of solution are suppose to go GAC and that makes solution a candidate for Global deployment.
Resolution:
Before you read the resolution below: Here's a comment that seems to be more better solution
"Better fix your solution by adding some dummy element that will make the solution deploy-able to a web application. If you have multiple web applications in your farm, usually you don't want to deploy your feature to all of them."
If that is not possible
Remove the URL parameter from STSADM. Do not use the Url parameter with the STSADM command while deploying or retracting such a solution
stsadm -o deploysolution -name SolutionFileName -local stsadm -o retractsolution -name SolutionFileName -local
Monday, March 22, 2010
How to get display form URL of a list item
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
SPListItem item = GetItem(); // some code to get a list item
SPList list = item.ParentList;
SPWeb web = list.ParentWeb;
string webUrl = web.Url;
string dispUrl = item.ContentType.DisplayFormUrl;
if(dispUrl == "")
dispUrl = list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url;
bool isLayouts = dispUrl.StartsWith("_layouts/",StringComparison.CurrentCultureIgnoreCase);
dispUrl = String.Format("{0}/{1}?ID={2}",webUrl,dispUrl,item.ID);
if(isLayouts)
dispUrl = String.Format("{0}&List={1}",dispUrl,SPEncode.UrlEncode(list.ID+""));As a result, you will get full display form URL of a list item. However, if you want to get just a “clickable” URL, to place in some hyperlink, you don’t need to write so much code. You may create URL by using only an address of a list display form. SharePoint will analyze provided ID of an item then and redirect your request to appropriate page. You may code just:
SPListItem item = GetItem(); // some code to get a list item
SPList list = item.ParentList;
SPWeb web = list.ParentWeb;
string webUrl = web.Url;
string dispUrl = list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url;;
dispUrl = String.Format("{0}/{1}?ID={2}",webUrl,dispUrl,item.ID);
Sunday, March 21, 2010
Troubleshooting SharePoint Alerts
http://sharepointalert.info/troubleshooting-sharepoint-alerts/
Wednesday, March 17, 2010
SharePoint DateTime Control Date Format
<SharePoint: DateTimeControl runat="server".... />
Put
LocaleId="2057"
before the /> bit at the end.
Sunday, March 14, 2010
Date Time Control In Sharepoint
<%@ Register TagPrefix="SharePointSD" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<div>
<table>
<tr>
<td style="width: 100px">
Start Date</td>
<td style="width: 100px">
<SharePointSD:DateTimeControl runat="server" ID="dteDemo1" DateOnly="True">
<asp:TextBox runat="server" MaxLength="45" CssClass="ms-input" ID="dtpDateTimeIdentifierTextBox1">
</asp:TextBox>
</SharePointSD:DateTimeControl>
</td>
<td style="width: 100px">
End Date</td>
<td style="width: 100px">
<SharePointSD:DateTimeControl runat="server" ID="dteDemo2" DateOnly="True">
<asp:TextBox runat="server" MaxLength="45" CssClass="ms-input" ID="dtpDateTimeIdentifierTextBox2">
</asp:TextBox>
</SharePointSD:DateTimeControl>
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td colspan="3">
<asp:CompareValidator id="cv" runat="server" ForeColor="red" Type="date" Operator="GreaterThan" ErrorMessage="End Date shoule be greater than start date"
ControlToCompare="dteDemo1$dteDemo1Date" ControlToValidate="dteDemo2$dteDemo2Date" ></asp:CompareValidator></td>
</tr>
</table>
</div>
