Monday, July 26, 2010

SharePoint, Javascript and Content Place Holder


want to add JavaScript in contentPage. Most of the time there are two ways -

1. Add javascript in master Page (as it can be added in <Head>)
2. Add javascript in Content Editor.

While coding I came across third way, which is very use full when you donot have web part zone (like Xlviewer.aspx) so there is no option of adding content editor web part, below is the coding style in content Page -

<asp:Content ContentPlaceHolderId="customCEPlaceHolder" runat="server">

<script type="text/javascript">
// <![CDATA[
function testing()


function getArgs() {

var args = new Object();
var query =;
var cntString = query.split("&");
var val=cntString[0].split('%2F');
var val1=decodeURI(val[1]);
var val2=decodeURI(val[2]);
var tempUrl = "/_layouts/temp.aspx?itemName="+val2+"&listName="+val1;
var myUrl = "/pages/gl.aspx?itemName="+val2+"&listName="+val1;
var caUlr = "/CA%20Collaboration/Forms/AllItems.aspx?itemName="+val2+"&listName="+val1;
//document.forms[0].action = caUlr ;

// ]]>

_spBodyOnLoadFunctionNames.push ensures that your function executes on page_load so it is equal as saying <page onLoad="" >

Try this you are saved from writting code for web part zone or saved from touching the master Page.


Thursday, July 8, 2010

Ribbon from SharePoint 2010 Pages


Just to share - Any body wants to get rid off top ribbon comes in every page with sharePoint? just comment javascript function -DisplayRibbonDiv();

when it is commented it will display ribbon on top, otherwise it won't.
Cheers :)

Monday, July 5, 2010

SharePoint Designer and 404 file not found, MasterPage using features and 404 error

Lastly I was working on masterpage, since my sharepoint portal integrates pages (old pages which includes runat=server) I am using MasterPage deployment using features. Everything was working perfactly fine. Suddenly I thought, I need some changes in UI and the debugging and troubleshooting started.

The issue is thus deployed masterpage, whenever I change and save, and again try to see it in browser it is giving me '404, resource or one of its dependacny could not be found' oh God. every thing was there not sure what I was missing.

After hours of struglling I thought to open master page using notepad rather than SharePoint Designer, oh and it worked like charm. the error gone. I am not sure what changed SPD was doing in file when I am opening it using SPD.

Posted this just to save time others struggling like me :)

Good Old  Notepad saved life.