Tuesday, August 10, 2010

SharePoint Development in Visual Studio

Visual Studio 2010 provides an alternative to creating SharePoint applications through SharePoint Designer. Visual Studio promotes rapid SharePoint development by providing such features as advanced debugging tools, IntelliSense, statement completion, and project templates. Visual Studio also takes advantage of advanced .NET Framework-based tools and languages. SharePoint projects can be developed by using either Visual Basic or Visual C#.

Read more

Friday, August 6, 2010

Reusable SharePoint JavaScript

Reusable SharePoint JavaScript
JSRequest
version: WSS 3.0 /source file: init.js (ln 1621)
purpose: provides method to parse query string, filename, and pathname from URL
example:
JSRequest.EnsureSetup();var qs = JSRequest.QueryString[value];var fn = JSRequest.FileName;var pt = JSRequest.PathName;
PreSaveAction()
version: WSS 3.0 source file: n/a (ref: form.js ln 5909)
purpose: provides hook for creating custom function interrupting submit action
example:
function PreSaveAction(){ var input = getTagFromIdentifierAndTitle("textarea","","Test"); if(input && input.value == "") { alert("You must complete Test"); return false; // Cancel the item save process } return true; // OK to proceed with the save item}
_spBodyOnLoadFunctionNames
version: WSS 3.0 source file: n/a
purpose: Allows you to register additional JavaScript methods that should run in the PageLoad event
example:
_spBodyOnLoadFunctionNames.Push('MyCustomFunctionName');
GetFirstChildElement(e)
version: WSS 3.0 source file: core.js
purpose: get the first "real" child of a DOM element. This function is useful for Firefox, which interprets a line break as a child element.
GetLastChildElement(e)
version: WSS 3.0 source file: core.js
purpose: get the last "real" child of a DOM element. This function is useful for Firefox, which interprets a line break as a child element.
GetCBSelectedValues(frm)
version: WSS 3.0 source file: core.js (ln 972)
purpose: Accepts a form object, loops through all check box elements and returns the values of the checked boxes or false if none are checked.
example:
html
lt; input id="spUserSelCb_1131" title="Raj" onclick="UserSelectionOnClick(this,'1');" type="checkbox" value="131" name="spUserSelectionCheckBox_1" gt;
JavaScript
var elm = document.getElementsByTagName("form")[0];GetCBSelectedValues(elm)
Object returned: strList = "131,144,143,7,254,22..."
GetSelectedValue (frmElem)
version: WSS 3.0 source file: init.js (ln 1516)
purpose: takes a form element with a
selectedIndex and returns the selected value or an empty string.
GetSelectedText(frmElem)
version: WSS 3.0 source file: init.js (ln 1523)
purpose: takes a form element with a
selectedIndex and returns the selected text or an empty string.
escapeProperly(str)
version: WSS 3.0 source file: init.js (ln 168)
purpose: takes any string and returns a
URL-encoded string.
example:
escapeProperly("this is a test")
"this%20is%20a%20test"
unescapeProperly(str)
version: WSS 3.0 source file: init.js (ln 855)
purpose: takes any
URL-encoded string and returns a string.
example:
unescapeProperly("this%20is%20a%20test")
"this is a test"
createNewDocumentWithProgID(strTemplate, strSaveLocation, strProgID, bXMLForm)
version: WSS 3.0 source file: Core.js (ln 1123)
purpose: Generates a new document in a document library using the supplyed document template
example:
createNewDocumentWithProgID('http:\u002f\u002fwssdev\u002fDocument Library\u002fForms\u002ftemplate.dotx', 'http:\u002f\u002fwssdev\u002fDocument Library', 'SharePoint.OpenDocuments', false)
This will open Word with a new document using the template located at http:\\fwssdev\Document Library\Forms\template.dotx and word will save to the Document Library located at http:\\fwssdev\Document Library

Friday, July 23, 2010

SharePoint 2010 Web part Development

Introduction to SharePoint 2010 Web part Development: Build and Deploy

1. Open VS.NET 2010 and create new project select SharePoint 2010

2.Start by using the Empty SharePoint Project template. Create an empty project[FW 3.5 or 4]. On the next dialogue, pick farm solution or sandboxed solutions. Provide the URL of the location to deploy. Ex:http://servername/sites/sitecollectionname
This will give a SharePoint project example : RajWebPart
3.Right click on the project and add new item and select Web part template type and enter project name as WebPart2010.

4.Add a new label and text.

5.Compile and deploy. The brilliant IDE will take of creating .webpart files and adding safe controls entry to the web.config file.



You can note a Feature files is automatically created and this web part is added as a Feature item. Set the Feature scope as Site. A package file is also given out of the box.


 
 
 
 
6.Checking the web part gallery, you can see WebPart2010.webpart file just created also preview it. Let’s add it to a page and see how it looks.
To Debug set a breakpoint and choose debug from the build menu like we add to any other type of project.
Enjoy!

Thursday, June 17, 2010

Auto Refresh Web Parts in SharePoint 2010

Automatic page refreshes were a big pain point in SharePoint 2007. If you had a page or list that you wished to refresh at regular intervals, so it the event that another user entered items, the screen would update, there was no easy/direct way of doing this. You could of could add meta content="50/" equi="refresh" using the Content Editor Web Part but this refreshes entire the entire page.
To overcome this, SharePoint 2010 introduces a new Ajax option has been added to many webparts to enable auto refresh of webpart without refreshing the entire web page. This feature is available out of the box in SharePoint 2010 and no additional development is required.
More

PowerShell for SharePoint

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell™ helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.
Built-in Windows PowerShell commands, called cmdlets, let you manage the computers in your enterprise from the command line. Windows PowerShell™ providers let you access data stores, such as the registry and certificate store, as easily as you access the file system. In addition, Windows PowerShell™ has a rich expression parser and a fully developed scripting language.

With SharePoint 2010 developers and administrators will have full access to the SharePoint API from the PowerShell Command line. Stsadm will continue to be supported and users will be able to continue using it however it will be depreciated over time. PowerShell is a lot more flexible and powerful.
More Details

Thursday, May 27, 2010

Global - Page inheritance in ASP.NET 2.0


The web.config file in ASP.NET 2.0 allows all pages to inherit from a specific base page class (instead of just using the default System.Web.UI.Page class in all pages).

To import the same set of namespaces on every page, just add them to an Imports sections under the pages element.
I hope this was not possible in 1.1 V.