Skip to main content

Posts

Showing posts with the label Publishing

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 , "

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

Sandbox ImageValueField Publishing

SPListItem theitem = SPContext .Current.Site.RootWeb.Lists[ "listname" ].GetItemById(1); string theImg = theitem .GetFormattedValue("ChallengeImage"); string theImgUrl =""; if(!string.IsNullOrEmpty(theImg)) {       theImgUrl  = XElement.Parse(ImgTag + "").Attribute("src").Value; }

PublishingAssociatedContentType

The Content Type to be associated with a page layout is indicated by the 'PublishingAssociatedContentType'. In the actual sense it means a binding setting between the Page Layout and the content type. If you fail to provide one, the SharePoint framework will make use of the Page Content type. The format of the binding is: ';# e.g. ';#ContentPage;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900470b13dd348649d08f9e5151501df9a4000dbd46dad8d045f98c83ad983b66d3f2;#'. where Content Type name: ContentPage Content Type ID: 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900470b13dd348649d08f9e5151501df9a4000dbd46dad8d045f98c83ad983b66d3f2 respectively. QED