Skip to main content

Posts

Showing posts from January, 2014

Add Web Visual Studio templates to SharePoint Project

Would you like to add the web user control to SharePoint 2007 project development.  Then open the project file with notepad and add {349c5851-65df-11da-9384-00065b846f21} to the ProjectTypeGUIDs node.   The necessary change is shown below: < ProjectTypeGuids > {349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} </ ProjectTypeGuids >

Register client side scripts in code behind

Quick way to register client side scripts.     Let us take the css files first: CssLink cssLink = new CssLink (); cssLink . DefaultUrl = "/_layouts/appname/cssfiletoregister.css" ; this . Page . Header . Controls . Add ( cssLink );     string scriptPath = "/_layouts/appname/jstoregister.js" ; if (! this . Page . ClientScript . IsClientScriptBlockRegistered ( scriptPath )) this . Page . ClientScript . RegisterClientScriptBlock ( this . GetType (), scriptPath , "

SharePoint URLs

 Got this idea from a good source and I need a backup for when I would need it. 1. Token: ~sitecollection ~site 2. SharePoint Server Token <% $SPUrl:~sitecollection/...%> 3. Emedded Code: <%=SPContext.Current.Site.ServerRelativeUrl %> You can use the embedded code any where in application page and web parts but don't use it in master page and page layout even though they seem work, because master page and page layout can be customized. The embedded code is only allowed in the uncustomized pages. 4. SharePoint Control: You can use the value returned by this control as control attribute but this is more like an hack, but it works. If you don't want to use it directly in attribute, you can use asp.net literal. < a href =" " >     < SharePoint : CssRegistration name ="<% $SPUrl:~sitecollection/_layouts/MortalityDB/css/custom.css %>" runat ="server" after ="SharepointCssFile"/> Here is...

Get Publishing HyperLink Field Value

The Publishing hyper link field value has some properties that you may want to extract for your use. Properties like: NavigateUrl, Target, Tooltip, Description, IconUrl Just pass in the field value name in your list.  LinkFieldValue pvalue = new LinkFieldValue(footerItem["FooterLink"].ToString());   your pvalue will then contain goodies. QED

Set Page Programmatically

The page title in SharePoint is located in the content place holder called PlaceHolderPageTitle.   You can change it by referencing the place holder and setting a value in.   ContentPlaceHolder cp= (ContentPlaceHolder)Page.Master.FindControl("PlaceHolderPageTitle"); cp.Controls.Clear(); cp.Controls.Add(new LiteralControl("The Title here"));   QED