Posts Tagged ‘MOSS’

Format Date and Time

Format date and time :

m_CalculatedOutOfOfficeStartDate = outOfOfficeStartDate.ToString("dd/MM/yyyy");
m_CalculatedOutOfOfficeEndDate = outOfOfficeEndDate.ToString("dd/MM/yyyy");

Hope this helps-


Create, Add, Delete content type (attach a custom document template)

July 9, 2012 1 comment

Creates a custom content type…attaches a custom document template with it…enables content types on document library…..deletes “Document” content type from the library….attaches our custom content type to it…

private void ProcessMyCVContentType(SPWeb web)
                web.AllowUnsafeUpdates = true;
                SPDocumentLibrary cvDocLib = web.Lists.TryGetList(Config.ListName_MyCVs) as SPDocumentLibrary;
                SPContentTypeId myContentTypeId = new SPContentTypeId("0x010100FA0963FA69A648AA916D2E41284FC3D5");
                SPContentType myContentType = web.ContentTypes[myContentTypeId];
                if (myContentType == null)
                    myContentType = new SPContentType(myContentTypeId, web.ContentTypes, "MyCVs");
                    myContentType.Group = "Custom Content Types";
                    myContentType.DocumentTemplate = "/my/_cts/myconenttypetemplate/template.dotx"; //SharedUrlUtility.EnsureTrailingSlash(web.ServerRelativeUrl) + Config.CVTemplatePath; //must be a relative url, no http:// etc in it.....otherwise u get "value does not fall within the expected range"......... 
SPFieldLink fieldLink = new SPFieldLink(cvDocLib.Fields["Primary"]);
                    fieldLink = new SPFieldLink(cvDocLib.Fields["Description"]);
                if (myContentType != null && cvDocLib != null)
                    cvDocLib.ContentTypesEnabled = true;
                    if (cvDocLib.ContentTypes["Document"] != null)
            catch (Exception ex)
                Log.LogError("MyProjName", ex);

make sure to put your custom template (e.g. customtemplate.dotx) at the specified location or a location of your choice (usually _cts folder is used for content types, see in sharepoint designer) and mention a relative url to it…….

Hope this helps-

Visual Studio 2012 Benefits

Create Lists and Content Types by Using New Designers
Create Site Columns
Create Silverlight Web Parts
Publish SharePoint Solutions to Remote SharePoint Servers
Test SharePoint Performance by Using Profiling Tools
Create Sandboxed Visual Web Parts
Improved Support for Sandboxed Solutions.
Support for JavaScript Debugging and IntelliSense for JavaScript
Streamlined SharePoint Project Templates
Test Your Code by Using Microsoft Fakes Framework

Error: cannot connect to performancepoint services

August 4, 2011 2 comments

Here is what worked for me:

Go to Central Admin > Application Management > Configure service application associations > click default.

You should see that PerformancePoint Services will be unchecked. Check that box and you should be good to go.

Hope this helps–

Javascript from within CSharp

This is how you can write javascript from within c#:

if (dtStart.SelectedDate != dtEnd.SelectedDate)
			    Response.Write(@"<script language='javascript'>alert('Start date must be equal to end date. Only hours and minutes can be different.');</script>");

Hope this helps-

Viewstate error on sharepoint custom page

March 2, 2011 2 comments

Created a custom aspx form in my sharepoint application. Put that under layouts folder. Placed a gridview control on it and started receiving the following error:

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)    at System.Web.UI.Control.AddedControl(Control control, Int32 index)    at xxxxx.SharePoint.EventsMgmt.BookingForm.RenderSearchResults(DataTable roomAvailabilityTable)    at Telstra.SharePoint.EventsMgmt.BookingForm.OnClickOK(Object Sender, EventArgs e)    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Set enableViewState=false in gridview tag on the aspx page…….(not code behind). solved the problem.

Hope this helps-


Creating Hot Spots on Images

March 2, 2011 5 comments

If you want to use an image with clickable areas within that image, you need to create hot-spots on that image such that when a person clicks on a particular area on that image, he is redirected to the specified URL.

Put your image into a content editor web part, go to source editor and below is how you can do it:

<MAP id=MenuLinks1 name=MenuLinks1>

<AREA title="Scope definition and freeze" href="http://sydtelfev02:8888/Program%20Management/Forms/AllItems.aspx?RootFolder=%2fProgram%20Management%2fHigh%2dlevel%20Release%20Cycle%20and%20supporting%20exhibits%2fScope%20definition%20and%20freeze&FolderCTID=&View=%7b2F8702E0%2dCEC2%2d4708%2d895B%2dD0EEA0875678%7d" shape="rect" coords="  3, 79, 64, 160">

<AREA title="Capability Planning" href="http://sydtelfev02:8888/Program%20Management/Forms/AllItems.aspx?RootFolder=%2fProgram%20Management%2fHigh%2dlevel%20Release%20Cycle%20and%20supporting%20exhibits%2fCapability%20Planning&FolderCTID=&View=%7b2F8702E0%2dCEC2%2d4708%2d895B%2dD0EEA0875678%7d" shape="rect" coords=" 3, 172, 64, 232">

<AREA title="Change Plan" href="http://sydtelfev02:8888/Program%20Management/Forms/AllItems.aspx?RootFolder=%2fProgram%20Management%2fHigh%2dlevel%20Release%20Cycle%20and%20supporting%20exhibits%2fChange%20Plan&FolderCTID=&View=%7b2F8702E0%2dCEC2%2d4708%2d895B%2dD0EEA0875678%7d" shape="rect" coords=" 3, 239, 64, 289">


<IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" id=MenuImage border=0 alt=Menu src="http://sydtelfev02:8888/SiteCollectionDocuments/PictorialDocumentTemplate4.JPG" useMap=#MenuLinks1>

shape = circle

shape = poly

are also available.

Hope this helps-