So you have a requirement to remove a webpart or multiple webparts from the webparts gallery in SharePoint and you need to do this with Windows PowerShell. One thing to remember is that the webparts gallery is the same as any other gallery in SharePoint and your task can easily be achieved using PowerShell. The below code will remove a webpart from the webparts gallery:
function RemoveWebPartsFromGallery([string]$siteUrl)
{
# an array of the custom webparts that were built;
$customWebPart = New-Object System.Collections.ObjectModel.Collection[System.String]
$customWebPart.Add("CustomWebPart")
$site = Get-SPSite $siteUrl
# the default SP type for a webpart gallery;
$wpCatalog = [Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog
$list = $site.GetCatalog($wpCatalog)
$wpID = New-Object System.Collections.ObjectModel.Collection[System.Int32]
foreach ($item in $list.items)
{
foreach ($wps in $customWebPart)
{
if ($item.Name.ToLower().Equals($wps))
{
$wpID.Add($item.ID)
continue
}
}
}
foreach ($i in $wpID)
{
$wpitem = $list.GetItemById($i)
$wpItem.Delete()
}
$list.Update()
Write-Host "WEBPARTS REMOVED FROM GALLERY" -ForegroundColor Green
}
You can check out the original script here a big thanks to Srinivas Challagolla for the script.
The script has greatly helped me I hope that it has helped you. Happy scripting guys :-)
Over the years, I’ve performed many technical roles — from hands-on engineering to enterprise architecture — and always found joy in sharing ideas through blogging. After a bit of a hiatus from blogging, I thought I’d start again and try my luck at putting thoughts out there. My hope is to spark collaboration, challenge assumptions, and maybe even help us do things a little better. So here are my ramblings for now…
Showing posts with label Sharepoint Custom Development. Show all posts
Showing posts with label Sharepoint Custom Development. Show all posts
Thursday, June 6, 2013
Wednesday, May 29, 2013
SharePoint Timer Jobs
How to create a SharePoint 2010 Timer Job...
So I have finally found sometime to create a post on how to create a SharePoint 2010 timer job. I had a look around and found many, many post already out there and they are awesome.
Please have a look at Andrew Connels blog post as it is a great resource to use for creating SharePoint timer jobs.
Another resource that I found very useful was SharePoint Tips for creating various timer job schedules.
So happy coding everyone, I hope these resources can help you.
Tuesday, May 14, 2013
Deploy SharePoint 2010 master page using a module
So this post may or may not be a bit overdue, but deploying various files with a module makes life for us as developers pretty simple. In this post I will detail the steps to deploy your custom developed SharePoint 2010 master page into the master page gallery.
So the first step is to create a new module in Visual Studio
By default the following files below are you created for you when a module is created, you can go ahead and delete the "Sample.txt" file as we will add our master page shortly.
You can down download a fantastic starter master create by Randy Drisgill from the following link.
Once you have downloaded the master page, add the master into the module.
Now once the master page has been added - open the "Elements.xml" file and add replace with the following:
And it is as simple as that - you can now deploy your custom built master page into the master page gallery with ease. I hope that this post has helped you.
Happy Branding :-)
So the first step is to create a new module in Visual Studio
By default the following files below are you created for you when a module is created, you can go ahead and delete the "Sample.txt" file as we will add our master page shortly.
You can down download a fantastic starter master create by Randy Drisgill from the following link.
Once you have downloaded the master page, add the master into the module.
Now once the master page has been added - open the "Elements.xml" file and add replace with the following:
Happy Branding :-)
SharePoint 2010 Test Cases including Test Matrix
In the last few months we were tasked to create test cases including a test matrix for what was developed in our SharePoint 2010 solution. So I started out on my Google Search trying to find a generic test document which I can reuse across my site as I did not want to write any test cases for the OTB functionality that SharePoint offers.
I found this link to provide good guidance in formulating a test plan as well as a test matrix document.
There are various other sources available on the Internet, but I have found the one mentioned above most useful for my specific requirements.
I hope this helps :-)
I found this link to provide good guidance in formulating a test plan as well as a test matrix document.
There are various other sources available on the Internet, but I have found the one mentioned above most useful for my specific requirements.
I hope this helps :-)
Monday, June 11, 2012
ASP.NET Update Panel not reloading jquery
Issue: asp.net update panel not reloading custom jquery after a partial post back occurs.
Cause: The asp.net update panel reloads all the content within the content template tags, thus your custom jquery is not reloaded and never fired.
Solution: Add your custom jquery at the end of the request by using the page request manager object:
And problem solved, it's as easy as that.
I hope this helped you, it solved my problem.
Cause: The asp.net update panel reloads all the content within the content template tags, thus your custom jquery is not reloaded and never fired.
Solution: Add your custom jquery at the end of the request by using the page request manager object:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
DOSTUFF();
});
And problem solved, it's as easy as that.
I hope this helped you, it solved my problem.
Friday, October 7, 2011
Create custom list using Content Type and Schema.xml file
Creating a schema for a custom SharePoint list has always been something I think which could be much improved upon, as it is always something that may cause you to pull out your own teeth.
In my experience the easiest way to do this is to replace the ContentType tags with the following:
Then it's as simple as adding your fields within the field tags of your schema.xml file, see below:
You can always use the GUID generator that comes with Visual Studio to generate new GUID's for your different fields.
Once complete, if you wish for your fields to be displayed in your view, add them to your ViewFields tags, (ViewFields tags can be found within the Views, View tag of your schema.xml file) as shown below:
You have now successfully created a working schema.xml file, hope this helps in stopping you from tearing your hair out.
How to access Init Parameters for SharePoint Silverlight Web Part
Custom initialisation parameters are accessible from within the silverlight web part, these values, are values passed from the Sharepoint Silverlight web part into the Silverlight application.
These values are passed in the form of a Dictionairy object and they are passed as follows:
These values are passed in the form of a Dictionairy object and they are passed as follows:
Key=Value,Key1=Value2These values can be accessed by using the following code:
private void Application_Startup(object sender, StartupEventArgs e)Please let me know if this post has helped you, and if you have any improvements or comments please feel free to post them.
{
string value = e.InitParams["Key"];
}
Tuesday, October 4, 2011
WCF Annonymous access is required for the IIS application that host this service.
When developing WCF web services for SharePoint you may sometimes run into the following problem.
Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
Trust me, you will knock your head trying to solve this one. The solution is pretty simple though. In your web.config file modify your the bindings section with the following:
If you SharePoint application is using Kerberos authentication please change the mode to Windows.
This solution worked for me, hope that it will work for you.
Till next
Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
Trust me, you will knock your head trying to solve this one. The solution is pretty simple though. In your web.config file modify your the bindings section with the following:
If you SharePoint application is using Kerberos authentication please change the mode to Windows.
This solution worked for me, hope that it will work for you.
Till next
Debuging Silverlight WebPart in SharePoint 2010
Debuging a silverlight web created and used in SharePoint 2010 can sometimes make you want to pull your hair out. I literally knocked my head against the wall a few times trying to get debugging to work. It's pretty simple though, all you need to do is select your project properties, click the sharepoint tab, and enable silverlight debugger.
For more information please refer to http://vangalvenkat.blogspot.com/2011/03/how-to-debug-silverlight-webpart-in.html it is a great resource and helped me to debug my silverlight application.
Until next time, hope this post has helped you as it certainly helped me.
For more information please refer to http://vangalvenkat.blogspot.com/2011/03/how-to-debug-silverlight-webpart-in.html it is a great resource and helped me to debug my silverlight application.
Until next time, hope this post has helped you as it certainly helped me.
Monday, July 18, 2011
WCF Service - Could not find a base address that matches schema http
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are []..
This is probably the most painfull error that I have ever experienced. After trying many fixes and googling for hours.
Problem : I only got this error when the web service was deployed to a Sharepoint web application that did not use a DNS entry to access the site. (Web service deployed to the ISAPI folder)
Fix : The solution which helped me was to remove the Base Address tags from my web.config file and my service worked. See below:
When I removed the above tags I no longer had problems accessing my webservice from my SharePoint site.
This is probably the most painfull error that I have ever experienced. After trying many fixes and googling for hours.
Problem : I only got this error when the web service was deployed to a Sharepoint web application that did not use a DNS entry to access the site. (Web service deployed to the ISAPI folder)
Fix : The solution which helped me was to remove the Base Address tags from my web.config file and my service worked. See below:
When I removed the above tags I no longer had problems accessing my webservice from my SharePoint site.
How to associate a workflow to a list programatically
Associating workflows to lists are pretty simple.
You will need the following:
Task List - Out of the box list
WorkFlowHistory List - Out of the box list
Workflow List - Workflow associate to this list
SPSecurity.RunWithElevatedPrivileges(delegate()
{
web.AllowUnsafeUpdates = true;
SPList taskList;
SPList workflowHistoryList;
SPList indexItemList = web.Lists[Constants.IndexItemList];
try
{
taskList = web.Lists[Constants.WFTasks];
}
catch
{
taskList = web.Lists[web.Lists.Add(Constants.WFTasks, Constants.WFTasks, SPListTemplateType.Tasks)];
}
try
{
workflowHistoryList = web.Lists[Constants.WFHistory];
}
catch
{
workflowHistoryList = web.Lists[web.Lists.Add(Constants.WFHistory, Constants.WFHistory, SPListTemplateType.WorkflowHistory)];
}
SPWorkflowTemplate template = web.WorkflowTemplates.GetTemplateByBaseID(new Guid(Constants.workFlowTemplateId));
SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, workflowHistoryList);
association.AllowManual = true;
association.AutoStartChange = true;
association.AutoStartCreate = true;
indexItemList.WorkflowAssociations.Add(association);
indexItemList.Update();
web.AllowUnsafeUpdates = false;
web.Update();
});
Workflow start properties may vary, please change as you see fit.
You will need the following:
Task List - Out of the box list
WorkFlowHistory List - Out of the box list
Workflow List - Workflow associate to this list
SPSecurity.RunWithElevatedPrivileges(delegate()
{
web.AllowUnsafeUpdates = true;
SPList taskList;
SPList workflowHistoryList;
SPList indexItemList = web.Lists[Constants.IndexItemList];
try
{
taskList = web.Lists[Constants.WFTasks];
}
catch
{
taskList = web.Lists[web.Lists.Add(Constants.WFTasks, Constants.WFTasks, SPListTemplateType.Tasks)];
}
try
{
workflowHistoryList = web.Lists[Constants.WFHistory];
}
catch
{
workflowHistoryList = web.Lists[web.Lists.Add(Constants.WFHistory, Constants.WFHistory, SPListTemplateType.WorkflowHistory)];
}
SPWorkflowTemplate template = web.WorkflowTemplates.GetTemplateByBaseID(new Guid(Constants.workFlowTemplateId));
SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, workflowHistoryList);
association.AllowManual = true;
association.AutoStartChange = true;
association.AutoStartCreate = true;
indexItemList.WorkflowAssociations.Add(association);
indexItemList.Update();
web.AllowUnsafeUpdates = false;
web.Update();
});
Workflow start properties may vary, please change as you see fit.
Friday, April 8, 2011
Features and their GUID’s in SP2010
Sick of trying to figure out the ID of a particular out of the box feature, all you need to do is download the excel spreadsheet I have created and you will have the ID for each and every out of the box feature in SharePoint.
Title | ID | Scope |
---|---|---|
$Resources:AccsrvWss | 1cc4b32c-299b-41aa-9770-67715ea05f25 | Farm |
Access Services System Objects | 29ea7495-fca1-4dc6-8ac1-500c247a036e | Web |
Access Services Restricted List Definition | a4d4ee2c-a6cb-4191-ab0a-21bb5bde92fb | Web |
$Resources:AccsrvWss | bcf89eb7-bca1-4468-bdb4-ca27f61a2292 | Web |
$Resources:AccsrvWss | 744b5fd3-3b09-4da6-9bd1-de18315b045d | Site |
$Resources:AccsrvWss | d5ff2d2c-8571-4c3c-87bc-779111979811 | Farm |
$Resources:AccsrvWss | 1a8251a0-47ab-453d-95d4-07d7ca4f8166 | Web |
Access Services User Application Log | 28101b19-b896-44f4-9264-db028f307a62 | Web |
Add Dashboard | d250636f-0a26-4019-8425-a5232d592c09 | Web |
Central Administration Links | fead7313-ae6d-45dd-8260-13b563cb4c71 | Web |
Administrative Reporting Infrastructure | b8f36433-367d-49f3-ae11-f7d76b51d251 | Site |
Administrative Reporting Core Pushdown Feature | 55312854-855b-4088-b09d-c5efe0fbf9d2 | Farm |
Announcements Lists | 00bfea71-d1ce-42de-9c63-a44004ce0104 | Web |
Asset Library | 4bcccd62-dcaf-46dc-a7d4-e38277ef33f4 | Site |
SharePoint Server Standard Site Collection features | b21b090c-c796-4b0f-ac0f-7ef1659c20ae | Site |
Base Site Features Stapling | 97a2485f-ef4b-401f-9167-fa4fe177c6f6 | Farm |
SharePoint Server Standard Site features | 99fe402e-89a0-45aa-9163-85342e865dc8 | Web |
SharePoint Server Standard Web application features | 4f56f9fa-51a0-420c-b707-63ecbb494db1 | WebApplication |
Basic Web Parts | 00bfea71-1c5e-4a24-b310-ba51c3eb7a57 | Site |
Document Center Enhancements | 3f59333f-4ce1-406d-8a97-9ecb0ff0337f | Web |
Dashboards Library | f979e4dc-1852-4f26-ab92-d1b2a190afc9 | Web |
DataConnections Library for PerformancePoint | 26676156-91a0-49f7-87aa-37b1d5f0c4d0 | Web |
Business Intelligence center sample data | 3992d4ab-fa9e-4791-9158-5ee32178e88a | Web |
SharePoint Portal Server Business Appications Content Type Definition | 43f41342-1a37-4372-8ca0-b44d881e4434 | Site |
SPS Biz Apps Field Definition | 5a979115-6b71-45a5-9881-cdc872051a69 | Site |
SharePoint Portal Server Status Indicator List template | 065c78be-5231-477e-a972-14177cc5b3c7 | Web |
BizApps Site Templates | 4248e21f-a816-4c88-8cab-79d82201da7b | Site |
Bulk workflow process button | aeef8777-70c0-429f-8a13-f12db47a6d47 | Farm |
Bulk Workflow Timer Job | d992aeca-3802-483a-ab40-6c9376300b61 | WebApplication |
Phone Call Memo List | 239650e3-ee0b-44a0-a22a-48292402b8d8 | Web |
Circulation List | a568770a-50ba-4052-ab48-37d8029b3f47 | Web |
Contacts Lists | 00bfea71-7e6d-4186-9ba8-c047ac750105 | Web |
Standard User Interface Items | 0f121a23-c6bc-400f-87e4-e6bbddf6916d | Farm |
Content Type Syndication Hub | 9a447926-5937-44cb-857a-d3829301c73b | Site |
Content type publishing | dd903064-c9d8-4718-b4e7-8ab9bd039fff | Web |
Standard Content Type Settings Links | fead7313-4b9e-4632-80a2-ff00a2d83297 | Farm |
Content type syndication | 34339dc9-dec4-4256-b44a-b30ff2991a64 | WebApplication |
Standard Content Type Definitions | 695b6570-a48b-4a8e-8ea5-26ea7fc1d162 | Site |
Custom Lists | 00bfea71-de22-43b2-a848-c05709900100 | Web |
Data Connections Feature | 00bfea71-dbd7-4f72-b8cb-da7ac0440130 | Web |
Data Connection Library | cdfa39c6-6413-4508-bccf-bf30368472b3 | Farm |
Data Source Libraries | 00bfea71-f381-423d-b9d1-da7a54c50110 | Web |
Content Deployment | ca2543e6-29a1-40c1-bba9-bd8510a4c17b | Web |
Discussion Lists | 00bfea71-6a49-43fa-b535-d15c05500108 | Web |
DM Content Type Setting Links | 1ec2c859-e9cb-4d79-9b2b-ea8df09ede22 | Farm |
Document ID Service | b50e3104-6812-424f-a011-cc90e6327318 | Site |
Document Libraries | 00bfea71-e717-4e80-aa17-d0c71b360101 | Web |
Document Sets metadata synchronization | 3a4ce811-6fe0-4e97-a6ae-675470282cf2 | WebApplication |
Content Organizer | 7ad5272a-2694-4349-953e-ea5ef290e97c | Web |
Document Routing Resources | 0c8a9a47-22a9-4798-82f1-00e62a96006e | Site |
Document Sets | 3bae86a2-776d-499d-9db8-fa4cdc7884f8 | Site |
Office.com Entry Points from SharePoint | a140a1ac-e757-465d-94d4-2ca25ab2c662 | Farm |
E-mail Integration with Content Organizer | d44a1358-e800-47e8-8180-adf2d0f77543 | Web |
Enhanced Html Editing | 81ebc0d6-8fb2-4e3f-b2f8-062640037398 | Farm |
Enhanced Theming | 068bc832-4951-11dc-8314-0800200c9a66 | Site |
Enterprise Wiki | 76d688ad-c16e-4cec-9b71-7b7f0d79b9cd | Web |
Enterprise Wiki Layouts | a942a218-fa43-4d11-9d85-c01e3e3a37cb | Site |
Events Lists | 00bfea71-ec85-4903-972d-ebe475780106 | Web |
Excel Services Farm Feature | e4e6a041-bc5b-45cb-beab-885a27079f74 | Farm |
Excel Services Site Feature | 3cb475e7-4e87-45eb-a1f3-db96ad7cf313 | Site |
e15ed6d2-4af1-4361-89d3-2acf8cd485de | WebApplication | |
Excel Services Site Feature | 4c42ab64-55af-4c7c-986a-ac216a6e0c0e | Site |
Excel Services Farm Feature | c6ac73de-1936-47a4-bdff-19a6fc3ba490 | Farm |
Disposition Approval Workflow | c85e5759-f323-4efb-b548-443d2216efb5 | Site |
External Lists | 00bfea71-9549-43f8-b978-e47e54a10600 | Web |
Resources List | 58160a6b-4396-4d6e-867c-65381fb5fbc9 | Web |
FAST Search for SharePoint Master Job Provisioning | d2d98dc8-c7e9-46ec-80a5-b38f039c16be | Farm |
Manage Resources | 08386d3d-7cc0-486b-a730-3b4cfe1b5509 | Web |
Feature Pushdown Links | 0125140f-7123-4657-b70a-db9aa1f209e5 | Farm |
Standard Column Definitions | ca7bd552-10b1-4563-85b9-5ed1d39c962a | Site |
Gantt Chart Tasks Lists | 00bfea71-513d-4ca0-96c2-6a47775c0119 | Web |
Group Work Provisioning | 6e8a2add-ed09-4592-978e-8fa71e6f117c | Web |
GroupBoardWebParts | 3d25bd73-7cd4-4425-b8fb-8899977f73de | Web |
Global Web Parts | 319d8f70-eb3a-4b44-9c79-2087a87799d6 | Farm |
Grid Lists | 00bfea71-3a1d-41d3-a0ee-651d11570120 | Web |
Group Work Lists | 9c03e124-eef7-4dc6-b5eb-86ccd207cb87 | Web |
Help | 071de60d-4b02-4076-b001-b456e93146fe | Site |
Hold and eDiscovery | 9e56487c-795a-4077-9425-54a1ecb84282 | Web |
Holidays List | 9ad4c2d4-443b-4a94-8534-49a23f20ba3c | Web |
Microsoft IME Dictionary List | 1c6a572c-1b58-49ab-b5db-75caf50692e6 | Web |
In Place Records Management | da2e115b-07e4-49d9-bb2c-35e93bb9fca9 | Site |
Admin Links for InfoPath Forms Services. | a10b6aa4-135d-4598-88d1-8d4ff5691d13 | Farm |
Admin Links for InfoPath Forms Services. | 750b8e49-5213-4816-9fa2-082900c0201a | Web |
InfoPath Forms Services support | c88c4ff1-dbf5-4649-ad9f-c6c426ebcbf5 | Site |
InfoPath Forms Services Tenant Administration | 15845762-4ec4-4606-8993-1c0512a98680 | Web |
InfoPath Forms Services Web Service Proxy Administration | 3c577815-7658-4d4f-a347-cfbb370700a7 | Web |
InfoPath Forms Services support | a0e5a010-1329-49d4-9e09-f280cdbed37d | Web |
Issues Lists | 00bfea71-5932-4f9c-ad71-1557e5751100 | Web |
Three-state workflow | fde5d850-671e-4143-950a-87b473922dc7 | Site |
Document Libraries | 6e53dd27-98f2-4ae5-85a0-e9a8ef4aa6df | Web |
SharePoint 2007 Workflows | c845ed8d-9ce5-448c-bd3e-ea71350ce45b | Site |
Links Lists | 00bfea71-2062-426c-90bf-714c59600103 | Web |
List Content Targeting | fc33ba3b-7919-4d7e-b791-c6aeccf8f851 | Farm |
SharePoint Portal Server Local Site Directory Capture Control | 14aafd3a-fcb9-4bb7-9ad7-d8e36b663bbd | Site |
Local Site Directory MetaData Capture Feature | 8f15b342-80b1-4508-8641-0751e2b55ca6 | Web |
Site Settings Link to Local Site Directory Settings page. | e978b1a6-8de7-49d0-8600-09a250354e14 | Site |
Library and Folder Based Retention | 063c26fa-3ccc-4180-8a84-b6f98e991df3 | Site |
Manage Profile Service Application | c59dbaa9-fa01-495d-aaa3-3c02cc2ee8ff | Farm |
SharePoint Portal Server Master Site Directory Capture Control | 8a663fe0-9d9c-45c7-8297-66365ad50427 | Farm |
Metadata Navigation and Filtering | 7201d6a4-a5d3-49a1-8c19-19c4bac6e668 | Web |
$Resources:xlsrv | 5a020a4f-c449-4a65-b07d-f2cc2d8778dd | Farm |
Excel Mobile Viewer Feature | e995e28b-9ba8-4668-9933-cf5c146d7a9f | Site |
Mobility Shortcut URL | f41cc668-37e5-4743-b4a8-74d1db3fd8a4 | Web |
Chart Web Part | 875d1044-c0cf-4244-8865-d2a0039c2a49 | Site |
Meetings Workspaces Web Parts | 39dd29fb-b6f5-4697-b526-4d38de4893e5 | Web |
My Site | 69cc9662-d373-47fc-9449-f18d11ff732c | Farm |
My Site Blogs | 863da2ac-3873-4930-8498-752886210911 | Site |
My Site Cleanup Feature | 0faf7d1b-95b1-4053-b4e2-19fd5c9bbc88 | Farm |
My Site Host | 49571cd1-b6a1-43a3-bf75-955acc79c8d8 | Site |
Shared Picture Library for Organizations logos | 5ede0a86-c772-4f1d-a120-72e734b3400c | Web |
My Site Layouts Feature | 6928b0e5-5707-46a1-ae16-d6e52522d52b | Site |
My Site Navigation | 6adff05c-d581-4c05-a6b9-920f15ec6fd9 | Web |
My Site Personal Site Configuration | f661430e-c155-438e-a7c6-c68648f1b119 | Site |
My Site Layouts Feature | 034947cc-c424-47cd-a8d1-6014f0e36925 | Web |
Portal Navigation | 89e0306d-453b-4ec5-8d68-42067cdbf98e | Site |
Portal Navigation Properties | 541f5f57-c847-4e16-b59a-b31e90e6f9ea | Web |
No-code Workflow Libraries | 00bfea71-f600-43f6-a895-40c0de7b0117 | Web |
BDC Profile Pages Feature | 683df0c0-20b7-4852-87a3-378945158fab | Web |
BDC Profile Pages Tenant Stapling Feature | 90c6c1e5-3719-4c52-9f36-34a97df596f7 | Farm |
Offline Synchronization for External Lists | d250636f-0a26-4019-8425-a5232d592c01 | Web |
Offline Synchronization for External Lists | f9cb1a2a-d285-465a-a160-7e3e95af1fdd | Farm |
Microsoft Office Server workflows | c9c9515d-e4e2-4001-9050-74f980f93160 | Site |
Open documents in client applications | 8a4b8de2-6fd8-41e9-923c-c7c3c00f8295 | Site |
Organizations Claim Hierarchy Provider | 9b0293a7-8942-46b0-8b78-49d29a9edd53 | Farm |
Office Server Site Search | bc29e863-ae07-4674-bd83-2c6d0aa5623f | WebApplication |
Search Central Admin Links | c922c106-7d0a-4377-a668-7f13d52cb80f | Farm |
Office Server Enterprise Search | 4750c984-7721-4feb-be61-c660c6190d43 | WebApplication |
$Resources:HealthReportsFeatureTitle; | e792e296-5d7f-47c7-9dfa-52eae2104c3b | Site |
Health Reports Pushdown Feature | 09fe98f3-3324-4747-97e5-916a28a0c6c0 | Farm |
Search Admin Portal Links and Navbar | edf48246-e4ee-4638-9eed-ef3d0aee7597 | Farm |
Shared Services Administration Links | 068f8656-bea6-4d60-a5fa-7f077f8f5c20 | Web |
Shared Services Navigation | 10bdac29-a21a-47d9-9dff-90c7cae1301e | Web |
Search Center URL | 7acfcb9d-8e8f-4979-af7e-8aed7e95245e | Web |
Site collection level Search Center Url Feature | 7ac8cc56-d28e-41f5-ad04-d95109eb987a | Site |
Document to Page Converters | 14173c38-5e2d-4887-8134-60f9df889bad | WebApplication |
Personalization Site | ed5e77f7-c7b1-4961-a659-0de93080fa36 | Web |
Picture Libraries | 00bfea71-52d4-45b3-b544-b1c71b620109 | Web |
Portal Layouts Feature | 5f3b0127-2f1d-4cfd-8dd2-85ad1fb00bfc | Site |
PerformancePoint Data Source Library Template | 5d220570-df17-405e-b42d-994237d60ebf | Web |
PerformancePoint Datasource Content Type definition | 05891451-f0c4-4d4e-81b1-0dabd840bad4 | Site |
PerformancePoint Services Site Collection Features | a1cb5b7f-e5e9-421b-915f-bf519b0760ef | Site |
PerformancePoint Services Site Features | 0b07a7f4-8bb8-4ec0-a31b-115732b9584d | Web |
PPS Site Stapling | 8472208f-5a01-4683-8119-3cea50bea072 | Farm |
PerformancePoint Monitoring | ee9dbf20-1758-401e-a169-7db0a6bbccb2 | Site |
PerformancePoint Content Type Definition | f45834c7-54f6-48db-b7e4-a35fa470fc9b | Site |
PerformancePoint Content List | 481333e1-a246-4d89-afab-d18c6fe344ce | Web |
SharePoint Server Enterprise Site Collection features | 8581a8a7-cf16-4770-ac54-260265ddb0b2 | Site |
Premium Site Features Stapling | a573867a-37ca-49dc-86b0-7d033a7ed2c8 | Farm |
SharePoint Server Enterprise Site features | 0806d127-06e6-447a-980e-2e90b03101b8 | Web |
SharePoint Server Enterprise Web application features | 0ea1c3b6-6ac0-44aa-9f3f-05e8dbe6d70b | WebApplication |
Profile Synchronization Feature | af847aa9-beb6-41d4-8306-78e41af9ce25 | Farm |
Publishing | 22a9ef51-737b-4ff2-9346-694633fe4416 | Web |
Page Layouts and Master Pages Pack | d3f51be2-38a8-4e44-ba84-940d35be1566 | Site |
Publishing Prerequisites | a392da98-270b-4e85-9769-04c0fde267aa | Site |
Publishing Resources | aebc918d-b20f-4a11-a1db-9ed84d79c87e | Site |
SharePoint Server Publishing Infrastructure | f6924d36-2fa8-4f0b-b16d-06b7250180fa | Site |
Publishing Features Stapling | 001f4bd7-746d-403b-aa09-a6cc43de7942 | Farm |
Publishing Timer Jobs | 20477d83-8bdb-414e-964b-080637f7d99b | WebApplication |
SharePoint Server Publishing | 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb | Web |
Ratings | 915c240e-a6cc-49b8-8b2c-0bff8b553ed3 | Site |
Record Resources | 5bccb9a4-b903-4fd1-8620-b795fa33c9ba | Site |
Records Center Configuration | e0a45587-1069-46bd-bf05-8c8db8620b08 | Web |
Records Management | 6d127338-5e7d-4391-8f62-a11e43b1d404 | Farm |
SharePoint Portal Server Redirect Page Content Type Binding Feature | 306936fd-9806-4478-80d1-7e397bfa6474 | Web |
Related Links scope settings page | e8734bb6-be8e-48a1-b036-5a40ff0b8a81 | Web |
Report Center Sample Data | c5d947d6-b0a2-4e07-9929-8e54f5a9fff9 | Web |
Reporting | 7094bd89-2cfe-490a-8c7e-fbace37b4a34 | Site |
SharePoint Portal Server Report Library | 2510d73f-7109-4ccc-8a1c-314894deeb3a | Web |
Publishing Approval Workflow | a44d2aa3-affc-4d58-8db4-f4a3af053188 | Site |
Publishing Workflow - SharePoint 2010 (en-US) | 19f5f68e-1b92-4a02-b04d-61810ead0409 | Site |
Routing Workflows | 02464c6a-9d07-4f30-ba04-e9035cf54392 | Site |
Routing Workflows - SharePoint 2010 | b5934f65-a844-4e67-82e5-92f66aafe912 | Site |
Routing Workflows - SharePoint 2010 (en-US) | 3bc0c1e1-b7d5-4e82-afd7-9f7e59b60409 | Site |
Schedule and Reservations List | 636287a7-7f62-4a6e-9fcc-081f4672cbf8 | Web |
Microsoft Search Administration Web Parts | c65861fa-b025-4634-ab26-22a23e49808f | Web |
Search And Process | 1dbf6063-d809-45ea-9203-d3ba4a64f86d | WebApplication |
Search extensions | 5eac763d-fbf5-4d6f-a76b-eded7dd7b0a5 | Site |
$Resources:SearchServerWizard_Feature_Title; | e09cefae-2ada-4a1d-aee6-8a8398215905 | Site |
Search Server Web Parts | eaf6a128-0482-4f71-9a2f-b1c650680e77 | Site |
Shared Services Infrastructure | f324259d-393d-4305-aa48-36e8d9a7a0d6 | Farm |
Collect Signatures Workflow | 6c09612b-46af-4b2f-8dfc-59185c962a29 | Site |
Collect Signatures Workflow - SharePoint 2010 | c4773de6-ba70-4583-b751-2a7b1dc67e3a | Site |
Collect Signatures Workflow - SharePoint 2010 (en-US) | a42f749f-8633-48b7-9b22-403b40190409 | Site |
Custom Site Collection Help | 57ff23fc-ec05-4dd8-b7ed-d93faa7c795d | Site |
Standard Site Settings Links | fead7313-4b9e-4632-80a2-98a2a2d83297 | Farm |
Sites List creation feature | a311bf68-c990-4da3-89b3-88989a3d7721 | Web |
Sku Upgrade Links | 937f97e9-d7b4-473d-af17-b03951b2c66b | Farm |
Slide Library | 0be49fe9-9bc9-409d-abf9-702753bd878d | Web |
Slide Library Activation | 65d96c6b-649a-4169-bf1d-b96505c60375 | Farm |
Social Tags and Note Board Ribbon Controls | 756d8a58-4e24-4288-b981-65dc93f9c4e5 | Farm |
Spell Checking | 612d671e-f53d-4701-96da-c3a4ee00fdc5 | Farm |
Portal DiscoPage Feature | 713a65a1-2bc7-4e62-9446-1d0b56a8bf7f | Farm |
Microsoft SharePoint Foundation Search feature | 2ac1da39-c101-475c-8601-122bc36e3d67 | WebApplication |
User Profile Administration Links | c43a587e-195b-4d29-aba8-ebb22b48eb1a | Farm |
Secure Store Service Admin | 35f680d4-b0de-4818-8373-ee0fca092526 | Web |
Office Workflows | ee21b29b-b0d0-42c6-baff-c97fd91786e6 | Farm |
Surveys Lists | 00bfea71-eb8a-40b1-80c7-506be7590102 | Web |
Tasks Lists | 00bfea71-a83e-497e-9ba0-7a5c597d0107 | Web |
Taxonomy feature stapler | 415780bf-f710-4e2c-b7b0-b463c7992ef0 | Farm |
Register taxonomy site wide field added event receiver | 73ef14b1-13a9-416b-a9b5-ececa2b0604c | Site |
Taxonomy Tenant Administration | 7d12c4c3-2321-42e8-8fb6-5295a849ed08 | Web |
Taxonomy Tenant Administration Stapler | 8fb893d6-93ee-4763-a046-54f9e640368d | Farm |
Create the taxonomy timer jobs | 48ac883d-e32e-4fd6-8499-3408add91b53 | WebApplication |
Team Collaboration Lists | 00bfea71-4ea5-48d4-a4ad-7ea5c011abe5 | Web |
Connect to Office Ribbon Controls | ff48f7e6-2fa1-428d-9a15-ab154762043d | Farm |
Tenant Business Data Connectivity Administration | 0a0b2e8f-e48e-4367-923b-33bb86c1b398 | Web |
Tenant Business Data Connectivity Administration Stapling | b5d169c9-12db-4084-b68d-eef9273bd898 | Farm |
Tenant Administration Content Deployment Configuration | 99f380b4-e1aa-4db0-92a4-32b15e35b317 | Web |
Tenant Administration Links | 98311581-29c5-40e8-9347-bd5732f0cb3e | Web |
$Resources:obacore | b738400a-f08a-443d-96fa-a852d0356bba | Web |
Secure Store Service Stapling Feature | 6361e2a8-3bc4-4ca4-abbb-3dfbb727acd7 | Farm |
Tenant User Profile Application | 32ff5455-8967-469a-b486-f8eaf0d902f9 | Web |
Tenant User Profile Application Stapling | 3d4ea296-0b35-4a08-b2bf-f0a8cabd1d7f | Farm |
Time Card List | d5191a77-fa2d-4801-9baf-9f4205c9e9d2 | Web |
Translation Management Workflow | c6561405-ea03-40a9-a57f-f25472942a22 | Site |
Translation Management Library | 82e2ea42-39e2-4b27-8631-ed54c1cfc491 | Farm |
Translation Management Library | 29d85c25-170c-4df9-a641-12db0b9d4130 | Web |
$Resources:UpgradeOnlyFile_Feature_Title; | 2fa4db13-4109-4a1d-b47c-c7991d4cc934 | Web |
Shared Service Provider User Migrator | f0deabbb-b0f6-46ba-8e16-ff3b44461aeb | Farm |
V2V Published Links Upgrade | f63b7696-9afc-4e51-9dfd-3111015e9a60 | Site |
V2V Publishing Layouts Upgrade | 2fbbe552-72ac-11dc-8314-0800200c9a66 | Site |
Restrict Limited Access Permissions | 7c637b23-06c4-472d-9a9a-7c175762c5c4 | Site |
Visio Process Repository | 7e0aabee-b92b-4368-8742-21ab16453d01 | Web |
Visio Process Repository | 7e0aabee-b92b-4368-8742-21ab16453d00 | Farm |
Visio Process Repository | 7e0aabee-b92b-4368-8742-21ab16453d02 | Web |
Visio Web Access | 5fe8e789-d1b7-44b3-b634-419c531cfdca | Farm |
Visio Web Access | 9fec40ea-a949-407d-be09-6cba26470a0c | Site |
Web Analytics Central Admin Customize Reports | 3ce24023-95a1-4778-85b0-8e9b2bcacc80 | Site |
Web Analytics Central Admin Reports | 786eaa5b-85d7-4ea0-8998-0b62c8befd94 | Site |
Web Analytics Customize Reports functionality | af6d9aec-7c38-4dda-997f-cc1ddbb87c92 | Site |
Web Analytics Enterprise Feature Stapler | c0c2628d-0f59-4873-9cba-100dad2313cb | Farm |
Web Analytics Feature Stapler | 9d46d0d4-af7b-4f2e-8f84-9466ab25766c | Farm |
Advanced Web Analytics | c04234f4-13b8-4462-9108-b4f5159beae6 | Site |
Advanced Web Analytics Reports | 2acf27a5-f703-4277-9f5d-24d70110b18b | Site |
Web Analytics Web Part | 8e947bf0-fe40-4dff-be3d-a8b88112ade6 | Site |
Wiki Page Library | 00bfea71-c796-4402-9f2f-0eb9a6e71b18 | Web |
Web Part Adder default groups | 2ed1c45e-a73b-4779-ae81-1524e4de467a | Site |
What's New List | d7670c9c-1c29-4f44-8691-584001968a74 | Web |
$Resources:core | 9c2ef9dc-f733-432e-be1c-2e79957ea27b | Web |
Wiki Page Home Page | 00bfea71-d8fe-4fec-8dad-01c19a6e4053 | Web |
WikiWelcome | 8c6a6980-c3d9-440e-944c-77f93bc65a7e | Web |
Workflow History Lists | 00bfea71-4ea5-48d4-a4ad-305cf7030140 | Web |
WorkflowProcessList Feature | 00bfea71-2d77-4a75-9fca-76516689e21a | Web |
Workflows | 0af5989a-3aea-4519-8ab0-85d91abe39ff | Site |
XML Form Libraries | 00bfea71-1e1d-4562-b56a-f05371 |
Tuesday, February 8, 2011
How to get your DLL information (Public Token Key, Version)
We are somtimes required many times to find out the exact information about DLL's we create. Sometimes this can pose a challenge and we sometimes get this slightly wrong. If you require to get information about a certain DLL please follow the steps below:
• Open up the Visual Studio command prompt
• Navigate to where your project DLL is stored (c:\projects\dummy\bin\debug)
• Type gacutil -i dummy.dll (The name of your DLL) This will add your assembly to the cache.
• Now type gacutil -l dummy (Your assembly name)
if you are however using .net 3.5 you can find the gacutil utility at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin, have a look in that directory as you can now find other utilities stored at the location.
The final step will give you all the relevant information about your DLL, now you can copy and paste it to where ever might be relevant.
I hope this post has helped you.
• Open up the Visual Studio command prompt
• Navigate to where your project DLL is stored (c:\projects\dummy\bin\debug)
• Type gacutil -i dummy.dll (The name of your DLL) This will add your assembly to the cache.
• Now type gacutil -l dummy (Your assembly name)
if you are however using .net 3.5 you can find the gacutil utility at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin, have a look in that directory as you can now find other utilities stored at the location.
The final step will give you all the relevant information about your DLL, now you can copy and paste it to where ever might be relevant.
I hope this post has helped you.
Wednesday, October 13, 2010
Creating Custom Web Part ToolPane
To create a custom toolpane is pretty simple, it's quite simple if you think about. All you need is an extra class that will create your toolpane.
I created a web part that had a custom toolpane that was used to display list in a site with checkboxes.
This toolpane allows users to select which list they wish to use on the site. Please see code below, and if you know of any better ways to do this please let me know:
WEB PART CODE EXAMPLE
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using SMC.ClassLibrary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
namespace OM.FILTER.JQUERY
{
[Guid("67e99305-67bc-444d-9f9d-0c3c53d3dfe8")]
[CLSCompliant(false)]
public class FilterJQuery : Microsoft.SharePoint.WebPartPages.WebPart
{
public FilterJQuery()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
public override ToolPart[] GetToolParts()
{
List _toolParts = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite _spSite = new SPSite("url"))
{
using (SPWeb _spWeb = _spSite.OpenWeb())
{
CustomToolPart _customPart = new CustomToolPart("url");
_customPart.Title = "All Lists";
_toolParts = new List(base.GetToolParts());
_toolParts.Insert(0, _customPart);
}
}
});
return _toolParts.ToArray();
}
[CLSCompliant(false)]
[WebBrowsable(false),
Personalizable(PersonalizationScope.Shared),
Category("Custom Settings")]
public string _collectionSelected
{
get;
set;
}
}
}
TOOL PANE CODE EXAMPLE
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;
using System.Data;
using SMC.ClassLibrary;
namespace OM.FILTER.JQUERY
{
class CustomToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
{
private CheckBoxList _spLists = new CheckBoxList();
private CheckBoxList chkBox
{
get { return _spLists; }
set { _spLists = value; }
}
private String _SiteURL;
public CustomToolPart(String _webURL)
{
this._SiteURL = _webURL;
}
protected override void CreateChildControls()
{
base.CreateChildControls();
BindToolPart();
}
private void BindToolPart()
{
chkBox.DataSource = Helper.GetAllListTitles(_SiteURL);
chkBox.DataTextField = "Title";
chkBox.DataValueField = "ID";
chkBox.DataBind();
FilterJQuery _jQuery = (FilterJQuery)this.ParentToolPane.SelectedWebPart;
if (_jQuery._collectionSelected != null)
{
List arrayList = Helper.SplitString(_jQuery._collectionSelected);
foreach (ListItem _item in chkBox.Items)
{
for (int i = 0; i < arrayList.Count; i++)
{
if (_item.Value == arrayList[i])
{
_item.Selected = true;
}
}
}
}
this.Controls.Add(chkBox);
}
public override void ApplyChanges()
{
base.ApplyChanges();
FilterJQuery parentWebPart = (FilterJQuery)this.ParentToolPane.SelectedWebPart;
string _iList = "";
foreach (ListItem _item in chkBox.Items)
{
if (_item.Selected)
{
_iList += _item.Value + ";";
}
}
parentWebPart._collectionSelected = _iList;
chkBox.EnableViewState = true;
EnableViewState = true;
this.SaveViewState();
this.SaveControlState();
}
}
}
Hope this helped you out as it sure helped me out a whole lot, let me know if you have any questions and I will try and respond to it asap.
I created a web part that had a custom toolpane that was used to display list in a site with checkboxes.
This toolpane allows users to select which list they wish to use on the site. Please see code below, and if you know of any better ways to do this please let me know:
WEB PART CODE EXAMPLE
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using SMC.ClassLibrary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
namespace OM.FILTER.JQUERY
{
[Guid("67e99305-67bc-444d-9f9d-0c3c53d3dfe8")]
[CLSCompliant(false)]
public class FilterJQuery : Microsoft.SharePoint.WebPartPages.WebPart
{
public FilterJQuery()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
public override ToolPart[] GetToolParts()
{
List
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite _spSite = new SPSite("url"))
{
using (SPWeb _spWeb = _spSite.OpenWeb())
{
CustomToolPart _customPart = new CustomToolPart("url");
_customPart.Title = "All Lists";
_toolParts = new List
_toolParts.Insert(0, _customPart);
}
}
});
return _toolParts.ToArray();
}
[CLSCompliant(false)]
[WebBrowsable(false),
Personalizable(PersonalizationScope.Shared),
Category("Custom Settings")]
public string _collectionSelected
{
get;
set;
}
}
}
TOOL PANE CODE EXAMPLE
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;
using System.Data;
using SMC.ClassLibrary;
namespace OM.FILTER.JQUERY
{
class CustomToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
{
private CheckBoxList _spLists = new CheckBoxList();
private CheckBoxList chkBox
{
get { return _spLists; }
set { _spLists = value; }
}
private String _SiteURL;
public CustomToolPart(String _webURL)
{
this._SiteURL = _webURL;
}
protected override void CreateChildControls()
{
base.CreateChildControls();
BindToolPart();
}
private void BindToolPart()
{
chkBox.DataSource = Helper.GetAllListTitles(_SiteURL);
chkBox.DataTextField = "Title";
chkBox.DataValueField = "ID";
chkBox.DataBind();
FilterJQuery _jQuery = (FilterJQuery)this.ParentToolPane.SelectedWebPart;
if (_jQuery._collectionSelected != null)
{
List
foreach (ListItem _item in chkBox.Items)
{
for (int i = 0; i < arrayList.Count; i++)
{
if (_item.Value == arrayList[i])
{
_item.Selected = true;
}
}
}
}
this.Controls.Add(chkBox);
}
public override void ApplyChanges()
{
base.ApplyChanges();
FilterJQuery parentWebPart = (FilterJQuery)this.ParentToolPane.SelectedWebPart;
string _iList = "";
foreach (ListItem _item in chkBox.Items)
{
if (_item.Selected)
{
_iList += _item.Value + ";";
}
}
parentWebPart._collectionSelected = _iList;
chkBox.EnableViewState = true;
EnableViewState = true;
this.SaveViewState();
this.SaveControlState();
}
}
}
Hope this helped you out as it sure helped me out a whole lot, let me know if you have any questions and I will try and respond to it asap.
Monday, October 4, 2010
Impersonating the Sharepoint System Account
Impersonating the SharePoint System Account is pretty simple. All you need is an the SPWeb object and you ready to go.
Here is how to do it.
using (SPWeb web = properties.OpenWeb())
{
var adminUser = web.AllUsers[@"SHAREPOINT\SYSTEM"];
var adminToken = adminUser.UserToken;
using (SPWeb site = new SPSite(web.Url, adminToken).OpenWeb())
{
/* Now running in the context of the system account */
}
}
And there it is, you can now run your code as the SharePoint System Account.
Here is how to do it.
using (SPWeb web = properties.OpenWeb())
{
var adminUser = web.AllUsers[@"SHAREPOINT\SYSTEM"];
var adminToken = adminUser.UserToken;
using (SPWeb site = new SPSite(web.Url, adminToken).OpenWeb())
{
/* Now running in the context of the system account */
}
}
And there it is, you can now run your code as the SharePoint System Account.
Storing Feature Values in Feature.XML file
Ever created a feature and wanted to deploy it on multiple servers without hard coding certain values?
It's kind of easy, you can use the feature.xml, namely the properties section to save values that you might want to change in future and then access them through code later, or even change them if need be.
In your feature.xml file, create a properties section, and add property tags for the relevant properties as shown below:

If you want to access this property you created you can do so by using the following code:
string _property = properties.Feature.Properties["SiteURL"].Value;
And that's it, how to access values stored in the feature.xml file.
It's kind of easy, you can use the feature.xml, namely the properties section to save values that you might want to change in future and then access them through code later, or even change them if need be.
In your feature.xml file, create a properties section, and add property tags for the relevant properties as shown below:

If you want to access this property you created you can do so by using the following code:
string _property = properties.Feature.Properties["SiteURL"].Value;
And that's it, how to access values stored in the feature.xml file.
Tuesday, July 27, 2010
Adding Event Reciever Programmatically
I was wondering one evening how would you programmatically add an event reciever to a SharePoint list programmatically, and then it hit me.
Get the Event Reciever collection for the specific list and just add your own event reciever to that collection, as shown below:
SPEventReceiverDefinitionCollection eventRecievers = spRequestList.EventReceivers;
SPEventReceiverDefinition defFile = spRequestList.EventReceivers.Add();
defFile.Name = "Auto Provisioning - Mark Parker";
defFile.Type = SPEventReceiverType.ItemAdded;
defFile.SequenceNumber = 10000;
defFile.Assembly = "SP2010.MarkParker, Version, Culture, PublicKeyToken=";
defFile.Class = "SP2010.MarkParker.EventReciever";
defFile.Update();
spRequestList.Update();
I have now added the Item added event to the list in question. If you wish to add the any other event recievers to the list simply follow the same method and just change the Type of event.
Hope this helped you
Get the Event Reciever collection for the specific list and just add your own event reciever to that collection, as shown below:
SPEventReceiverDefinitionCollection eventRecievers = spRequestList.EventReceivers;
SPEventReceiverDefinition defFile = spRequestList.EventReceivers.Add();
defFile.Name = "Auto Provisioning - Mark Parker";
defFile.Type = SPEventReceiverType.ItemAdded;
defFile.SequenceNumber = 10000;
defFile.Assembly = "SP2010.MarkParker, Version, Culture, PublicKeyToken=";
defFile.Class = "SP2010.MarkParker.EventReciever";
defFile.Update();
spRequestList.Update();
I have now added the Item added event to the list in question. If you wish to add the any other event recievers to the list simply follow the same method and just change the Type of event.
Hope this helped you
Programmatically Adding SharePoint List
Adding list programmatically is pretty simple, all you need to do is grab the list collection for the current site and add a new list as shown below:
SPListCollection ListCollection = _spweb.Lists;
ListCollection.Add("Name", "Decription", SPListTemplateType.GenericList);
Its that simple you have just added a list called name with the description description to your sharepoint site.
SPListCollection ListCollection = _spweb.Lists;
ListCollection.Add("Name", "Decription", SPListTemplateType.GenericList);
Its that simple you have just added a list called name with the description description to your sharepoint site.
Wednesday, July 21, 2010
Custom Consumer Web Part
Retrieving data from another web part by means of connections is pretty simple. In the code example I will show you how you can create your own consumer web part that will allow you to recieve a row of data from another web part, custom or out of the box.
Code Example :
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
using System.Text;
namespace MarkAnthonyParker.ConsumsumerWebPart
{
[ToolboxItemAttribute(false)]
public class ConsumsumerWebPart: WebPart
{
private IWebPartRow _provider;
private DataRowView _tableRow;
protected override void RenderContents(HtmlTextWriter writer)
{
if (_tableRow != null)
{
// Add method to use data
}
}
private void GetRowData(object tableRowData)
{
_tableRow = (DataRowView)tableRowData;
}
protected override void OnPreRender(EventArgs e)
{
if (_provider != null)
{
_provider.GetRowData(new RowCallback(GetRowData));
}
}
[ConnectionConsumer("Row")]
public void SetConnectionInterface(IWebPartRow provider)
{
_provider = provider;
}
public class TableConsumerConnectionPoint : ConsumerConnectionPoint
{
public TableConsumerConnectionPoint(System.Reflection.MethodInfo callbackMethod, Type interfaceType, Type controlType, string name,
string id, bool allowMultipleConnections)
: base(callbackMethod, interfaceType, controlType, name, id, allowMultipleConnections)
{
}
}
}
}
This code can be used for both SharePoint 2007 and SharePoint 2010 web parts.
Code Example :
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
using System.Text;
namespace MarkAnthonyParker.ConsumsumerWebPart
{
[ToolboxItemAttribute(false)]
public class ConsumsumerWebPart: WebPart
{
private IWebPartRow _provider;
private DataRowView _tableRow;
protected override void RenderContents(HtmlTextWriter writer)
{
if (_tableRow != null)
{
// Add method to use data
}
}
private void GetRowData(object tableRowData)
{
_tableRow = (DataRowView)tableRowData;
}
protected override void OnPreRender(EventArgs e)
{
if (_provider != null)
{
_provider.GetRowData(new RowCallback(GetRowData));
}
}
[ConnectionConsumer("Row")]
public void SetConnectionInterface(IWebPartRow provider)
{
_provider = provider;
}
public class TableConsumerConnectionPoint : ConsumerConnectionPoint
{
public TableConsumerConnectionPoint(System.Reflection.MethodInfo callbackMethod, Type interfaceType, Type controlType, string name,
string id, bool allowMultipleConnections)
: base(callbackMethod, interfaceType, controlType, name, id, allowMultipleConnections)
{
}
}
}
}
This code can be used for both SharePoint 2007 and SharePoint 2010 web parts.
Monday, July 12, 2010
Attempted to use an object that has ceased to exist
Error : Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))
This error occurs when you are using the SPContext.Current.Web object and then trying to dispose it.
So, do not dispose of this object or other controls on your page will no longer be able to use it. Thus the error, attempted to use an object that has ceased to exist.
SharePoint will automatically dispose of the SPContext.Current.Web object once your page has completely loaded.
This error occurs when you are using the SPContext.Current.Web object and then trying to dispose it.
So, do not dispose of this object or other controls on your page will no longer be able to use it. Thus the error, attempted to use an object that has ceased to exist.
SharePoint will automatically dispose of the SPContext.Current.Web object once your page has completely loaded.
Subscribe to:
Posts (Atom)