Hi,
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 = window.location.search.substring(1);
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 ;
//document.forms[0].submit();
window.open(myUrl,'_self');
}
_spBodyOnLoadFunctionNames.push("testing");
// ]]>
</script>
</asp:Content>
_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.
Cheers
Monday, July 26, 2010
Thursday, July 8, 2010
Ribbon from SharePoint 2010 Pages
hi,
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 :)
Ruchi
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 :)
Ruchi
Monday, July 5, 2010
SharePoint Designer and 404 file not found, MasterPage using features and 404 error
hi,
Lastly I was working on masterpage, since my sharepoint portal integrates asp.net pages (old asp.net 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.
Lastly I was working on masterpage, since my sharepoint portal integrates asp.net pages (old asp.net 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.
Thursday, May 27, 2010
JSOM or Excel Service Java Script Model
hi,
It's high time to reveal another screte which microsoft is shipping with SPS 2010. For some it may not be screte but I am sure the code snippet is screte for most of the readers. let's jump to topic directly.
The New functionality is Editable excel sheet, which means the user can edit sheet in EWA. more detailed is - developer uses Excel Web Access EWA to render excel sheet in SharePoint, Till MOSS it was just readonly now user can edit the sheet there only. How it is possible?
The developer team introduced another property 'Allow Type and Formula' which is visible from web part properties, once this check box is checked user can edit the sheet right away.
now why I am so excited about this -> hey it gives us javascript based Object Model to interact with rendered sheet. Ideally what I do is use on content editor web part and assosiate it wih .txt file which contains javascript code.
So below is small snippet about setting selected value using Javascript OM -
function setCellValue(selectedValue)
{
ewa= Ewa.EwaControl.getInstances().getItem(0); // --get handle of currently rendered workbook
workbook = ewa.getActiveWorkbook(); // handle of active workbook;
rangelocal = workbook.getActiveCell(); //handle of active cell
var column = rangelocal.getColumn(); //
var row = rangelocal.getRow();
var valueArray = new Array(1);
valueArray[0] = new Array(1);
valueArray[0][0] = selectedValue;
rangelocal.setValuesAsync(valueArray,asyncCallbackSet,'SetValue');
}
function asyncCallbackSet(asyncResult)
{
}
lets talk highlighted Text. we will reverse track here, will start from green one.
asyncResult gives option to trace error using asyncResult.getCode() and asyncResult.getDescription()
excecute this simple code and feel the power.
worth mentioshing is since SPS 2010 supports silverlight OOB , and communication between Silverlight and Javascript is possible ..now the power is just double :) and this Object model give you control for excel events like cell changed, tab out etc.
Enjoy :)
It's high time to reveal another screte which microsoft is shipping with SPS 2010. For some it may not be screte but I am sure the code snippet is screte for most of the readers. let's jump to topic directly.
The New functionality is Editable excel sheet, which means the user can edit sheet in EWA. more detailed is - developer uses Excel Web Access EWA to render excel sheet in SharePoint, Till MOSS it was just readonly now user can edit the sheet there only. How it is possible?
The developer team introduced another property 'Allow Type and Formula' which is visible from web part properties, once this check box is checked user can edit the sheet right away.
now why I am so excited about this -> hey it gives us javascript based Object Model to interact with rendered sheet. Ideally what I do is use on content editor web part and assosiate it wih .txt file which contains javascript code.
So below is small snippet about setting selected value using Javascript OM -
function setCellValue(selectedValue)
{
ewa= Ewa.EwaControl.getInstances().getItem(0); // --get handle of currently rendered workbook
workbook = ewa.getActiveWorkbook(); // handle of active workbook;
rangelocal = workbook.getActiveCell(); //handle of active cell
var column = rangelocal.getColumn(); //
var row = rangelocal.getRow();
var valueArray = new Array(1);
valueArray[0] = new Array(1);
valueArray[0][0] = selectedValue;
rangelocal.setValuesAsync(valueArray,asyncCallbackSet,'SetValue');
}
function asyncCallbackSet(asyncResult)
{
}
lets talk highlighted Text. we will reverse track here, will start from green one.
- setValuesAsync() is the function responsible for setting range value using async call back.
- asyncCallbackSet is my call back function, 'SetValue' is context.
- valueArray this is the 2-Dimensional array contains value for the cell. Now why it is 2 - dimensional as it is excel where cell is row and column, so the first index represents row and second column.
asyncResult gives option to trace error using asyncResult.getCode() and asyncResult.getDescription()
excecute this simple code and feel the power.
worth mentioshing is since SPS 2010 supports silverlight OOB , and communication between Silverlight and Javascript is possible ..now the power is just double :) and this Object model give you control for excel events like cell changed, tab out etc.
Enjoy :)
Monday, May 17, 2010
SharePoint 2010 Certification
hi,
let's wait for new certication from microsoft till then use below information to be ready for first exam :)
70-573 - 12th July 2010
For more about this -
keep waiting :)
let's wait for new certication from microsoft till then use below information to be ready for first exam :)
70-573 - 12th July 2010
For more about this -
keep waiting :)
Subscribe to:
Posts (Atom)
