Working with SharePoint Lists in Visual Studio .NET

Creating QR Code 2d barcode in Visual Studio .NET Working with SharePoint Lists

Working with SharePoint Lists
Scan QR Code 2d Barcode In .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
QR Drawer In .NET
Using Barcode maker for .NET framework Control to generate, create QR-Code image in VS .NET applications.
In this example, we use a numeric value as input to the Template parameter To find out a template s corresponding numeric Type value, you can use the showTemplate switch parameter
Scanning QR Code ISO/IEC18004 In .NET Framework
Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Paint Bar Code In .NET
Using Barcode drawer for .NET Control to generate, create bar code image in VS .NET applications.
PS > New-SPList -url http://nimaintranet/site -showTemplate
Read Barcode In VS .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in VS .NET applications.
Create QR-Code In Visual C#.NET
Using Barcode creator for .NET Control to generate, create Denso QR Bar Code image in .NET applications.
When creating a list using the SharePoint object model and the simple Add method overload that we used in our function, the list may not appear on the Quick Launch navigation bar (based on the value of the OnQuickLaunch property of the corresponding list template), so we may need to add this link manually We can achieve this by setting the OnQuickLaunch property to True The property is provided by the SPList class, so first we need to retrieve an instance of SPList containing the list we just created
QR Code 2d Barcode Creation In VS .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.
Drawing Denso QR Bar Code In Visual Basic .NET
Using Barcode encoder for .NET framework Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
Getting List Instances
Barcode Generation In .NET
Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in .NET framework applications.
Linear Maker In .NET Framework
Using Barcode encoder for .NET Control to generate, create Linear image in Visual Studio .NET applications.
The simplest way of getting a instance of our new list is by typing this:
Creating Matrix Barcode In .NET Framework
Using Barcode creator for VS .NET Control to generate, create Matrix 2D Barcode image in VS .NET applications.
Encoding ISSN - 13 In Visual Studio .NET
Using Barcode drawer for VS .NET Control to generate, create ISSN image in .NET framework applications.
PS > $spWebLists["My Calendar"]
Painting Barcode In .NET Framework
Using Barcode printer for Reporting Service Control to generate, create bar code image in Reporting Service applications.
Generate DataMatrix In Visual C#
Using Barcode printer for VS .NET Control to generate, create ECC200 image in .NET applications.
The problem with this line of code is that it loads the metadata of all available lists, then performs a comparison of the Title property, and finally returns the lists where the title matches This approach might consume a lot of memory if performed against a site with many lists A better approach is to use the GetList method supported by SPWeb The GetList method accepts a list s full or relative URL as input In this example, we use a site-relative URL:
Create European Article Number 13 In None
Using Barcode drawer for Online Control to generate, create UPC - 13 image in Online applications.
Painting Code 39 In Java
Using Barcode maker for Android Control to generate, create USS Code 39 image in Android applications.
PS > $spList = $spWebGetList("/Lists/My Calendar")
Linear Maker In Java
Using Barcode drawer for Java Control to generate, create Linear Barcode image in Java applications.
Data Matrix 2d Barcode Generation In None
Using Barcode generator for Online Control to generate, create ECC200 image in Online applications.
The following Get-SPList function also retrieves a list instance
Make ECC200 In None
Using Barcode creator for Office Word Control to generate, create Data Matrix image in Microsoft Word applications.
Code128 Printer In Objective-C
Using Barcode creation for iPhone Control to generate, create Code 128 Code Set B image in iPhone applications.
function Get-SPList([uri]$url) { # Nullify variables $site, $web and $list $site = $web = $list = $null # Get site collection $site = New-Object -TypeName MicrosoftSharePointSPSite ` -ArgumentList $( [MicrosoftSharePointUtilitiesSPEncode]::UrlDecodeAsUrl($urlAbsoluteUri) ); # Get site-relative URL $webURL = ([MicrosoftSharePointUtilitiesSPEncode]::UrlDecodeAsUrl( $urlAbsoluteUri) ) -replace $siteUrl; # Remove query information if included if (-not [string]::IsNullOrEmpty($urlQuery)) { $webURL = $webURLReplace($urlQuery, [string]::Empty); }
PowerShell for Microsoft SharePoint 2010 Administrators
# Process the array of segments backwards, # removing segments one by one from the end of the URL, # until the URL of the lowest level subsite is identified -1-($urlSegmentsCount) | ForEach-Object { if ($web -eq $null) { # Once the correct URL is obtained, initialize a variable containing an # instance of SPWeb class for the lowest level subsite if($webUrl -eq "/"){ $identity = $webUrl } else { $identity = $webUrlTrim("/") } $web = Get-SPWeb -Site $site -Identity $identity ` -ErrorAction SilentlyContinue; $webUrl = $webUrl -replace ` [MicrosoftSharePointUtilitiesSPEncode]::UrlDecodeAsUrl( $urlSegments[$_] ); } } if ($web -ne $null) { 0($urlSegmentsCount - 1) | ForEach-Object { $listUrl += $urlSegments[$_]; if ($list -eq $null) { $list = $(trap {continue}; $webGetList($listUrlTrimEnd("/"))); } } } $webDispose(); $siteDispose(); return $list; }
You can use the function by typing the following:
PS > $spList = Get-SPList -url "http://nimaintranet/site/Lists/My Calendar"
NOTE From this point on, we ll use the Get-SPList function in all functions and scripts that handle lists and libraries in SharePoint 2010
Adding Lists to the Quick Launch Bar
When you have retrieved an instance of SPList using any of the methods demonstrated previously, you can set the OnQuickLaunch property to True and update the list This will add a link to a list in the Quick Launch bar
14:
Working with SharePoint Lists
PS > $spListOnQuickLaunch = $true PS > $spListUpdate()
The Set-SPListOnQuickLaunch function shown next demonstrates how to add and remove lists from the Quick Launch navigation The function uses the Get-SPList function presented in the previous section to retrieve an instance of SPList
function Set-SPListOnQuickLaunch ([uri]$url, [switch]$add, [switch]$remove) { # Use the Get-SPList function to retrieve a list $spList = Get-SPList -url $url if($spList) { if($add) { $spListOnQuickLaunch = $true; } if($remove) { $spListOnQuickLaunch = $false; } $spListUpdate(); } }
The Set-SPListOnQuickLaunch function either adds or removes a link to a list from the Quick Launch bar To add a list, type this:
PS > Set-SPListOnQuickLaunch ` >> -url "http://nimaintranet/site/Lists/My Calendar" -add
To remove a list, use the remove switch
PS > Set-SPListOnQuickLaunch ` >> -url "http://nimaintranet/site/Lists/My Calendar" -remove
Deleting Lists
You can also delete lists in SharePoint 2010 using Windows PowerShell Simply retrieve the list using the Get-SPList function, and then use the Delete method provided by the SPList class
PS > $spList = Get-SPList -url "http://nimaintranet/site/Lists/My Calendar" PS > $spListDelete()
Copyright © OnBarcode.com . All rights reserved.