Posts

Showing posts from January, 2014

Update a web part programmatically

This is an example how we can update a web part programmatically in multiple sites. LiteralControl lit = new LiteralControl(); lit.Text = ""; try { using (SPSite site = new SPSite(SPContext.Current.Web.Site.RootWeb.Url)) { for (int i = 1; i < site.AllWebs.Count; i++) { lit.Text += "<BR/>" + site.AllWebs[i].Title; SPFile file=site.AllWebs[i].GetFile(site.AllWebs[i].ServerRelativeUrl + "/default.aspx"); if ( file.Exists) { using (Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager wpm = site.AllWebs[i].GetLimitedWebPartManager(file.Url, PersonalizationScope.Shared)) { foreach (WebPart wp in wpm.WebParts) { if (wp.Title == "Notes") { wp.Height = new Unit("200px"); wpm.SaveChanges(wp); break; } } } } } } } catch (Exception ex) { lit.Text += "<BR/>" + ex.ToString(); } this.Controls.Add(lit);

Use HTML and JavaScript in Calculated Field / Column

Here I found some good examples which shows how to use html & javascripts in calculated columns like if you want to show progress bar in task list based on percent completed or change color of font based on certain condition or put any symbol or highlight row based on any condition. Please check below given links for the same : http://sharepointwijzer.nl/sharepoint-blog/tech/icc-html-calculated-column-sharepoint-view/ http://www.pentalogic.net/sharepoint-products/free-stuff/html-calculated-column/hcc-example-uses