Sometimes you need to search for some sub controls and its ID doesn’t depends on you. For example, you don’t know how this control will be rendered in different conditions. Like SharePoint fields are rendered. You know that there must be one TextBox (… or other type) which you need to use to do some trick with it.
Following code can help you:
public static T FindControl<T>(Control control) where T : Control
{
foreach (Control c in control.Controls)
{
if (c is T)
{
return (T)c;
}
if (c.HasControls())
{
T cTmp = FindControl<T>(c);
if (cTmp != null)
{
return cTmp;
}
}
}
return null;
}
Using example:
TextBox c = FindControl<TextBox>(Page);
if (c == null)
{
// Control not found
}
You can also modify this method to collect all controls of required type.
Iterating through SPSiteCollection and SPWebCollection is a pretty simple, because getting these collections is a simple.
SharePoint API doesn’t provide any method to get collection of all Web Applications in a farm. Here we need to write more code, than we are getting collections of SPSite or SPWeb.
- SPWebService provides collection of SPWebApplication, but it is only a part of all Web Applications, because SPFarm have many SP Web Services.
- Getting all services in a SP Farm:
- SPServiceCollection services = SPFarm.Local.Services;
- Here we should choose only Services which is of type SPWebService
- iterating through all services in a SPServiceCollection and check which is of type SPWebService
- if (curService is SPWebService) …
- Now we can iterate through all services and all web applications inside them
The final code can be something like this:
SPServiceCollection services = SPFarm.Local.Services;
foreach (SPService curService in services)
{
if (curService is SPWebService)
{
SPWebService webService = (SPWebService)curService;
foreach (SPWebApplication webApp in webService.WebApplications)
{
// here you can do something with webApp
}
}
}
Windows Server 2008 R2 is compatible only with Office SharePoint Server 2007 with Service Pack 2.
At a moment Microsoft have not released a version of MOSS with built in Service Pack 2.
So if you will try to install MOSS without service pack or with SP 1 you will get following error:
All what you need is to create own slip-streamed installation of SharePoint Server with Service Pack 2 included.
Microsoft have an official how-to create an installation source that includes software updates:
http://technet.microsoft.com/en-us/library/cc261890.aspx
After that you have possibility to install MOSS with SP2 on your Windows Server 2008 R2
Appending strings performance test
String += creates new instance of object and saves it in memory, as a result you have 2 string objects in a memory. For this kind of targets .NET have class named StringBuilder which will work 2500 times faster than string += or trick with string.Format (which is a very bad idea). StringBuilder holds all data in one memory instance and changes it, not creates a new instance each time as it do += for string.
So better practice for appending strings is to use StringBuilder.
C# code:
int iterations = 100000;
string testString = string.Empty;
// string += test (using string.Concat will return the same result)
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < iterations; ++i)
{
testString += i.ToString();
}
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
sw.Reset();
// string.Format test
testString = string.Empty;
sw.Start();
for (int i = 0; i < iterations; ++i)
{
testString = string.Format("{0}{1}", testString, i.ToString());
}
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
sw.Reset();
// StringBuilder test
StringBuilder sb = new StringBuilder();
sw.Start();
for (int i = 0; i < iterations; ++i)
{
sb.Append(i.ToString());
}
testString = sb.ToString();
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
Console.ReadKey();
|
Results:
- string += appending : 176 654 ms
- string.Format appending : 456 265 ms
- StringBuilder.Append() : 68 ms
Listing of Web Parts available in SharePoint 2010
Navigation
• Categories
• Site Aggregator
• Sites in Category
• Summary Links
• Table of Contents
• Tag Cloud
Lists & Libraries
• These are list view web parts for the lists and document libraries
Authoring
• Content Editor
• Image Viewer, same as in SharePoint 2007
• Media Web Part
• Page Viewer
• Silverlight Web Part
Business Data
• Business Data Actions
• Business Data Catalog Filter
• Business Data Item
• Business Data Item Builder
• Business Data List
• Business Data Related List
• Key Performance Indicators
• KPI Details
• Visio Graphics Service
Content Rollup
• Chart Viewer
• Content Query
• HTML Form Web Part
• iView
• Picture Library Slideshow Web Part
RSS Viewer
• What’s Popular – pick from content, search queries, or search results;
XML Viewer
Documents
• Document ID Lookup
• Document Set Contents
• Document Set Properties
• Relevant Documents
Filters
• Choice Filter
• Current User Filter
• Date Filter
• Filter Actions
• Page Field Filter
• Query String (URL) Filter
• SharePoint List Filter
• SQL Server Analysis Services Filter
• Text Filter
My Information
• My Calendar
• My Contacts
• My Inbox
• My Mail Folder
• My Tasks
Office Client Applications
• Excel Web Access
• InfoPath Form Web Par
WSRP Viewer
People
• Contact Details
• Profile Browser
• Site Users
• User Task
PerformancePoint
• PerformancePoint Filter
• PerformancePoint Report
• PerformancePoint Scorecard
• PerformancePoint Stack Selecto
Search
• Advanced Search Box
• Dual Chinese Search
• Featured Content
• Federated Results
• People Refinement Panel
• People Search Box
• People Search Core Results
• Refinement Panel
• Related Queries
• Search Action Links
• Search Best Bets
• Search Box
• Search Core Results
• Search Paging
• Search Statistics
• Search Summary
• Top Federated Result
Miscellaneous
• Chart Web Part