Saturday, May 30, 2009

Save As Word Document Script

The following JS code will save the inner text of an element like ‹Div id="Save"›, the server must have Microsoft word installed on it and it works only on IE.

function SaveAsWord()
{
var sp = document.getElementById("Save");
var docApp = new ActiveXObject("Word.Application");
var doc = new ActiveXObject("Word.Document");
doc.Application.Visible=false;
doc.Content=sp.innerText;
// Show Save Dialog
doc.Save()
doc.Application.Quit();
}

Add To Favorites Script

function AddToFavorites()
{
var url = document.location.href;

if (window.sidebar)
{
// Mozilla Firefox
window.sidebar.addPanel(document.title, url ,"");
}
else if( window.external )
{
// IE
window.external.AddFavorite(url , document.title);
}
}

Saturday, March 21, 2009

VSeWSS 1.3 (Mar 2009 CTP)

Visual Studio 2008 extensions for Windows SharePoint Services 3.0, v1.3 - Mar 2009 CTP

The tools provide item templates for List Definition, List Definition from Content Type, Content Type, Field Control, Web Part, Module, Root File, Template, Event Receiver, and List Instance. It provides project templates for Team Site Definition, Blank Site Definition, List Definition, Web Part and Empty. It works with Visual Basic .NET and C# languages and a comprehensive user guide is included. It does not include the SharePoint Workflow templates as they are built in with Visual Studio 2008.

Sunday, March 08, 2009

Cross SharePoint Permission When Anonymouse Allowed

When Working With Anonymouse You Some Proplems in Permission The RunWithElevatedPrivileges Method Allow You to Executes a specified Code or method with Full Control rights even if the user does not otherwise have Full Control

SPSecurity.RunWithElevatedPrivileges(delegate()
{

//You Must Create SPSite Object and SPWeb Object Here

// Add Your Code Here Like Add Item to SharePoint List

});

Tuesday, February 24, 2009

SharePoint PreSaveAction


You can use below JavaScript function to execute any JavaScript Code in New or Edit Forms for SharePoint List before saving (When Pressing OK button this function will be fired first)

You can use this function for validation before PostBack

PreSaveAction()
{
    //Add Your JavaScript Code Here Then Return True Or False

    return false; // Cancel the item save process

    return true; // OK to proceed with the save item
}

Get Value of any SharePoint Control Using JavaScript

You can Get any Form Field Value By Using This JS Function

function getTagFromIdentifierAndTitle(TagName, Identifier, Title)
{
var len = Identifier.length;
var tags = document.getElementsByTagName(TagName);
for (var i=0; i < tags.length; i++)
{
var tempString = tags[i].id;
if (tags[i].title == Title && (Identifier == "" tempString.indexOf(Identifier) == tempString.length - len))
{ return tags[i]; }
}
return null;
}

Ex:
getTagFromIdentifierAndTitle('input','TextField', 'Title').value

Monday, February 23, 2009

SharePoint Site Backup and Restore Batch

Just copy backup part or restore part and past it in a new file then save it as *.bat

Backup Batch

Echo Site BackUp

@SET STSADM="%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe"

pause

%STSADM% -o backup -url http://localhost:2009/ -filename "FileName.bak" -overwrite
%STSADM% -o execadmsvcjobs

Restore Batch

Echo Restore Site

@SET STSADM="%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe"

pause

%STSADM% -o restore -url http://localhost:5000/ -filename "FileName.bak" -overwrite
%STSADM% -o execadmsvcjobs

Sum Of List Column



< xsl:value-of select="sum(/dsQueryResponse/Rows/Row/@ColumnName)" />

Saturday, February 07, 2009

SharePoint 2007 Built-in JS Functions


//Get Current User ID  i.e - alert(_spUserId);
_spUserId

//Run JS Function on Page Load
_spBodyOnLoadFunctionNames.push('FunctionName');

//First we must call the EnsureSetup method
JSRequest.EnsureSetup();

//Get a query string parameter called ItemId. i.e - "page.aspx?ItemId=11" will return 11
itemId = JSRequest.QueryString["ItemId"];

//Get the current page name. i.e - "default.aspx"
pageName = JSRequest.FileName;

//Get the current path name. i.e - "/doclib/default.aspx"
path = JSRequest.PathName;

SharePoint RPC Protocol (URL Protocol)

//Get List items in XML format
http://localhost/_vti_bin/owssvr.dll?XMLDATA=1&List={ ListDUID }

//Get List items where FieldName = Value in XML format
http://localhost/_vti_bin/owssvr.dll?XMLDATA=1&List={ ListGUID }&View={ ViewGUID }&FilterField1= FieldName &FilterValue1= Value

you can try it in your browser and see the result

For More >>