Posts

Showing posts from 2011

SharePoint Anonymous Access to SharePoint Sites

  http://www.google.com.vn/search?gcx=c&sourceid=chrome&ie=UTF-8&q=ViewFormPagesLockDown http://sharepoint.stackexchange.com/questions/7279/anonymous-access-for-blog-sites-not-working-in-sp2010 http://social.technet.microsoft.com/Forums/en-US/sharepointsocialcomputing/thread/e4eefc4f-d0f1-43fb-bc2f-4b32fc98d320 http://www.sharepointblues.com/2010/12/22/blog-site-in-anonymous-use/ http://www.c-sharpcorner.com/uploadfile/Roji.Joy/how-to-secure-external-anonymous-access-to-sharepoint-2010-sites/

Escape/unescape strings between JavaScript and ASP.NET

  Ref: http://www.garrypassarella.co.uk/2011/05/18/escapeunescape-strings-between-javascript-and-asp-net/ The Microsoft.JScript library has a couple of handy methods for just this. You will have to reference this in your project by right clicking References and adding a reference to the library. Response.Write(Microsoft.JScript.GlobalObject.escape(quote)); space –> %20 & –> %26 ….

SharePoint Technical Libraries (For IT Pro)

  Microsoft SharePoint Server 2010 Technical Library in Compiled Help format Microsoft FAST Search Server 2010 for SharePoint Technical Library in Compiled Help format Microsoft Project Server 2010 Technical Library in Compiled Help format Microsoft SharePoint Foundation 2010 Technical Library in Compiled Help format

SharePoint Multi-languages with JavaScript Code

A my friend asked me how to implement Multi-languages with JavaScript in SharePoint 2010. With server code, you can use resourced for this. With JavaScript, you can identify the current language that SharePoint Site is using via _spPageContextInfo object (Ref: http://trungpv.blogspot.com/2011/09/javascript-notes-with-sharepoint.html ), it provides the currentLanguage property that allows you know which language is using. You can define an JavaScript objects like below: News.DefaultLanguage = 1033; News.Resources = {}; //English News.Resources[1033] = {     Title: "News",     Function: "Searcj" }; //Vietnamese News.Resources[1066] = { Title: "Tin tức", Function: "Tìm kiếm" }; And you can load appropriated resources: if (News.Resources[_spPageContextInfo.currentLanguage]) {             res = News.Resources[_spPageContextInfo.currentLanguage];         } else { ...

JavaScript Notes with SharePoint

  Understanding the _spPageContextInfo variable in SharePoint 2010 Adding JavaScript code Behind a SharePoint 2010 Page Introduction to SharePoint Object Model

Notes with Custom Document ID in MOSS 2010

Image
ma MOSS 2010 provides Document ID Services that allows get the document with unique key, and do not care about the document or folder will be renamed. You can develop a Custom Document ID Services and can define the format of DocumentID. You need to take care about: * DoCustomSearchBeforeDefaultSearch This is a variable with Boolean datatype, if it sets TRUE, the custom GetDocumentUrlsById will be call before the default Search function and FALSE for default Search function. But if the GetDocumentUrlsById return an empty array, the default Search function will be called. * GetDocumentUrlsById Incase you override this method, if you did not found the document never return an array string with one empty item you will get an exception (a Microsoft trap ? ) string[] res = new string[1]; res[0] = string.Empty;       public override string[] GetDocumentUrlsById(SPSite site, string documentId)         {      ...

Copy DLL(s) from C:\Windows\Assembly

  Run following command: subst x: C:\Windows\assembly”. You will have a virtual Driver that map with C:\Windows\Assemby http://en.wikipedia.org/wiki/Subst

Bug in FilterFieldV3 function (SharePoint core.js)

Image
  In SharePoint List Views, when you want to display the Filter Choices , you can add a parameter to URL : &Filter=1  or use SP Designer to add a parameter for XSLTListViewWebPart: Name: Filter; Value: 1 This works fine with Field Name that do not contain special characters or space. But with the Field Name contains special characters or space, the Reset Filter does not work fine: 1. 2.     The Views did not reset data for this. The problem come from: FilterFieldV3 function (in core.js) On this function, via call to CanonicalizeUrlEncodingCase, the Url will be changed the FilterField from f –> F Example: "Roll%5fx0020%5fOut%5fx0020%5fPhase" –> "Roll%5Fx0020%5FOut%5Fx0020%5FPhase" Default%20Filter.aspx?View={37BE24A2-9C85-4C92-A655-EC7B10CAD8D4}&FilterField1=Roll%5 f x0020%5 f Out%5 f x0020%5 f Phase&FilterValue1=Phase%202&Filter=1 -> Default%20Filter.aspx?View={37BE24A2-9C85-4C92-A655-EC7B10CAD8D4}&FilterField1=Roll%5 ...

Fixing the Personal View in SP 2010 (with Delegate Control)

Please note that the below source code should be applied for SP 2010 without SP1 and June – 2011 CU.. //Fixing the Personal View string strView = Request.QueryString[ "ShowWebPart" ]; if (! string .IsNullOrEmpty(strView) && control != null ) { if ( SPContext .Current != null ) { if ( SPContext .Current.List != null ) { SPView spView = SPContext .Current.List.Views[ new Guid (strView)]; if (spView.PersonalView) { //Fixing the Page Title try { Control pageTitleControl = this .findControl( this .Page, "PlaceHolderPageTitle" ); Control currentViewTitleControl = pageTitleControl.Controls[2]; currentViewTitleControl.Visible = false ; pageTitleControl.Controls.Add( new LiteralControl (spView.Title)); } catch { } //Fixing ...

Useful Design Pattern

http://www.dotnetage.com/publishing/library

Custom Controls in XSLT

  Ref: https://www.nothingbutsharepoint.com/sites/devwiki/articles/Pages/Custom-Controls-in-XSLT.aspx

Missing DropDown menu for choosing of views

  Ref: http://vintentou.wordpress.com/2010/08/03/missing-dropdown-menu-for-choosing-of-views/   Find row … <SharePoint:ListTitleViewSelectorMenu AlignToParent="true" id="LTViewSelectorMenu" runat="server" /> and replace with… <SPAN id=onetidPageTitleSeparator><SPAN><SPAN style="POSITION: relative; WIDTH: 11px; DISPLAY: inline-block; HEIGHT: 11px; OVERFLOW: hidden"><IMG style="POSITION: absolute; BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; TOP: -585px !important; LEFT: 0px !important" alt=: src="/_layouts/images/fgimg.png"></SPAN></SPAN></SPAN> <SharePoint:ViewSelectorMenu ID="viewSelectorMenu1" runat="server" />   http://www.pentalogic.net/sharepoint-products/free-stuff/view-rescue

Control the render of SharePoint Page

If you want to control the render of SharePoint Page like disable the controls, add new control, hide ribbon menu, ECB Menu….you can user the delegate control to do it: <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ 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" %> <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%...

Adding/Removing toolbar from custom ListViewWebPart

Refer from: Last week I got a requirement to develop a web part which will display a SharePoint list’s data together with some other content. And the SharePoint list’s data should be displayed same as displayed in the default SharePoint list view. So to display list data, I used SharePoint’s out-of-the-box webpart named ListViewWebPart which can be found in the Microsoft.SharePoint.WebPartPages namespace. Refer following code snippet: public class CustomListViewWebPart : WebPart {   protected override void CreateChildControls()   {     base.CreateChildControls();     //Code to add ListViewWebPart     SPWeb web = SPContext.Current.Web;     SPList list = web.Lists[“CustomListName”];     SPView wpView = list.Views[“ViewName”];     ListViewWebPart _wpListView = new ListViewWebPart();     _wpListView.ID = "_wpListView";     _wpListView.ListName = list.ID.ToStri...

Hiding a Single Button on Ribbon and Site Actions Menu

  Run following method in the Page_Load method, you can use delegate control or custom control (.ascx) to implement this. protected void Page_Load(object sender, EventArgs e) { } Hide a Ribbon public void HideRibbon() { SPRibbon current = SPRibbon.GetCurrent( this .Page); if (current != null && ! this .Page.Request.IsAuthenticated) {   current.CommandUIVisible = false ; } }   Hide a Button on Ribbon SPRibbon ribbon = SPRibbon.GetCurrent(this.Page); if (ribbon != null) {   SPUser currentUser = SPContext.Current.Web.CurrentUser;   if (currentUser.LoginName.Equals("loginname",StringComparison.InvariantCultureIgnoreCase)) { ribbon.TrimById("Ribbon.Library.Actions.OpenWithExplorer"); }   Hide Status Bar public void HideStatusBar() { string script = "document.onreadystatechange=fnRemoveAllStatus; function fnRemoveAllStatus(){removeAllStatus(true)};" ; this .Page.ClientScript.RegisterClientScriptBlock( typeof (HideTheRibbon), ...

SharePoint JavaScript On Demand SPSOD

http://www.ilovesharepoint.com/2010/08/sharepoint-scripts-on-demand-spsod.html Update: If you want to modify Item’s ECB Menu, please do not make a copy of core.js. Change     <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand=" true " runat="server"/> ->     <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand=" false " runat="server"/>   Add another webpart at the end of the page, override the “AddCheckinCheckoutMenuItem” (for hiding “Publish a Major Version”) function AddCheckinCheckoutMenuItem(m, ctx, url) {ULSsa6:;     var menuOption;     if(!HasRights(0x0, 0x4))         return;     if (currentItemCheckedOutUserId==SYSTEM_ACCOUNT_ID && ctx.CurrentUserId !=SYSTEM_ACCOUNT_ID)         return;     if (currentItemCheckedOutUserId==null)     ...

Hide a custom field from the Document Information Panel

  Set ShowInFileDlg to FALSE   static void SetShowInFileDlg(SPField f, bool value) { XmlDocument fieldSchemaXml = new XmlDocument(); fieldSchemaXml.LoadXml(f.SchemaXml); XmlAttribute attr = fieldSchemaXml.CreateAttribute( "ShowInFileDlg" ); attr.Value = value.ToString().ToUpper(); XmlNode fieldXmlNode = fieldSchemaXml.SelectSingleNode( "Field" ); XmlAttributeCollection fieldAttributes = fieldXmlNode.Attributes; fieldAttributes.Append(attr); f.SchemaXml = fieldXmlNode.OuterXml; f.Update( true ); }

Allow anonymous access to SharePoint application pages in the _layouts directory

  By default, the page is inherited from “LayoutsPageBase”. Change the inheritance from “LayoutsPageBase” to “UnsecuredLayoutsPageBase”.  public partial class HelloWorld : UnsecuredLayoutsPageBase Next, we need to override a property of the UnsecuredLayoutsPageBase, to allow the anonymous access. Be sure to change the ‘getter’ to return true  protected override bool AllowAnonymousAccess { get { return true; } }

SharePoint: Group By on more than 2 columns in a view

  http://techtrainingnotes.blogspot.com/2008/11/sharepoint-group-by-on-more-than-2.html http://techtrainingnotes.blogspot.com/2011/01/sharepoint-group-by-on-more-than-2.html

Adding custom Style for List View

  http://www.novolocus.com/2008/09/18/adding-a-custom-view-style-to-moss-2007-or-wss3/ http://vkirshin.blogspot.com/2011/04/customizing-boxed-no-labels-view-style.html

Register CSS to SP Master Page

http://mosshowto.blogspot.com/2010/06/sharepoint-2010-registering-css.html http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/fc22110f-c83a-48ae-9f18-6a38a672e568/ protected override void OnPreRender(EventArgs e)         {             base.OnPreRender(e);             CssRegistration css = new CssRegistration();             css.Name=SPContext.Current.Web.Url +"/css/mcstyle.css";             css.After = "corev4.css";             this.Controls.Add(css);         }

SharePoint Expression

  Very cool http://spexpressions.codeplex.com