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.

Friday, April 16, 2010

“Client-only Framework subset” in Visual Studio 2008

The .NET Framework Client Profile setup contains just those assemblies and files in the .NET Framework that are typically used for client application scenarios. For example: it includes Windows Forms, WPF, and WCF. It does not include ASP.NET and those libraries and components used primarily for server scenarios. Approx. 26MB in size, and it can be downloaded and installed much quicker than the full .NET Framework setup package. For more info Click here

Thursday, April 8, 2010

SilverLight WebPart

To Develop Silverlight WebPart
1.Create a Silverlight Application first, compile it to get the .XAP file.
2.Create a WebPart project add the Silverlight .XAP file like this
Example

protected override void CreateChildControls()
{
//base.CreateChildControls();
System.Web.UI.SilverlightControls.Silverlight myMediaCtrl = new System.Web.UI.SilverlightControls.Silverlight();
myMediaCtrl.ID = "RajMediaPlayer";
myMediaCtrl.Source = "http://rajwss.com/rajss1/monkDocumentLib/RajMediaPlayer.xap";// media files can be uploaded to this same Document Library.
myMediaCtrl.Width = new System.Web.UI.WebControls.Unit(900);
myMediaCtrl.Height = new System.Web.UI.WebControls.Unit(650);

this.Controls.Add(myMediaCtrl);

}
3.Compile it and deploy to the server.
Server Side changes

1.Install Silverlight SDK on the Sharepoint Server.
The Silverlight SDK can be downloaded from : http://www.microsoft.com/downloads/details.aspx?FamilyID=8D933343-038F-499C-986C-C3C7E87A60B3&displaylang=en
After the SDK has been installed make sure the System.Web.Silverlight.dll assembly has been registered in the GAC.
i also installed Silverlight.exe(V 3.0) in the server(not required though)
2. Make the following changes to the SharePoint Site web.config file
Add the following to the configuration (copy to NotePad Replace lt; to < & gt; to > )

Add the following to the lt;configurationgt;lt;configSectionsgt; xml:

lt;sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"gt;
lt;sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"gt;
lt;section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /gt;
lt;sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"gt;
lt;section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /gt;
lt;section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /gt;
lt;section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /gt;
lt;section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /gt;
lt;/sectionGroupgt;
lt;/sectionGroupgt;
lt;/sectionGroupgt;

Add the following to the lt;configurationgt;lt;Sharepointgt;lt;SafeControlsgt; xml:

lt;SafeControl Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" /gt;
lt;SafeControl Assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" /gt;

Add the following to the lt;configurationgt;lt;system.webgt;lt;httpHandlersgt; xml:

lt;remove verb="*" path="*.asmx" /gt;
lt;add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /gt;

Add the following to the lt;configurationgt;lt;system.webgt;lt;compilationgt;lt;assembliesgt; xml:

lt;add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /gt;
lt;add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /gt;
lt;add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /gt;
lt;add assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;

Add the following to the lt;configurationgt;lt;system.webgt;lt;pagesgt; xml:

lt;controlsgt;
lt;add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;/controlsgt;

Add the following to the lt;configurationgt;lt;runtimegt;lt;assemblyBindinggt; xml:

lt;dependentAssemblygt;
lt;assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" /gt;
lt;bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /gt;
lt;/dependentAssemblygt;
lt;dependentAssemblygt;
lt;assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" /gt;
lt;bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /gt;
lt;/dependentAssemblygt;

Add the following to the lt;configurationgt; xml:

lt;system.webServergt;
lt;validation validateIntegratedModeConfiguration="false" /gt;
lt;modulesgt;
lt;remove name="ScriptModule" /gt;
lt;add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;/modulesgt;
lt;handlersgt;
lt;remove name="WebServiceHandlerFactory-Integrated" /gt;
lt;remove name="ScriptHandlerFactory" /gt;
lt;remove name="ScriptHandlerFactoryAppServices" /gt;
lt;remove name="ScriptResource" /gt;
lt;add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /gt;
lt;/handlersgt;
lt;securitygt;
lt;authorizationgt;
lt;add accessType="Allow" users="" /gt;
lt;add accessType="Allow" users="?" /gt;
lt;/authorizationgt;
lt;/securitygt;
lt;/system.webServergt;

3.To add the Silverlight XAP to the IIS MIME-Type complete the following steps:
Open IIS
Open up the properties for the IIS Web Server
Click MIME Types...
Click New...
Enter ".xap" for the Extension
Enter "application/x-silverlight-app" for the MIME type
Click Ok, Ok, Apply
4. Restart IIS.

5.Add the deployed WebPart to the page.

For the complete code check
http://www.vbforums.com/archive/index.php/t-557072.html