I have created a webpart and want to deploy that in Sharepoint. I want to deploy the web part in bin.
I have not created a strong name for dll (webpart code). Is strong name a must for deploying webpart in bin folder?
I have referred this msdn link to do this.
http://technet.microsoft.com/en-us/library/cc263271.aspx
When I go to WebPart gallery and want to populate a web part, it is not appearing in webpart gallery.
Any help will be appreciated.
Strong name isn't a must for Sharepoint development, but is your easiest option.
You could also to use WSPBuilder (SharePoint WSP tool) to deploy your webparts
I usually strong name my assemblies because I don't want to discover it later on that my assemblies needs a strong name, just in case the assembly is being used in some other way than I originally intended.
I've also had some problems relating to events in Sharepoint where reflection is used to execute functions based on class and assembly info (probably stored in database), so if you add a strong name later on then you have to update the places where the old event was used (e.g. on lists), otherwise your functions won't get hit. On the other hand if you have a strong name then this is easy bu using web.config assembly redirect
I like your idea though of having the assembly in bin, that way you can use CAS which provides more control for administrators.
To resolve this problem then you could start out by adding the strong name and deploying the asembly to the GAC, then add your .webpart (or .dwp) to the web part gallery. If that works you can try moving the assembly to the bin folder and then remove the strong name.
You might consider deploying the webpart in a feature and add the code neccessary to add the .webpart file to the gallery on the fly so you dont have to worry about the file, this can be accomplished by using code using a feature receiver
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates = true;
SPList list = web.Lists["Web Part Gallery"];
SPFolder root = list.RootFolder;
SPFile spFile = root.Files.Add("ContentEditor.dwp", s);
spFile.Update();
}
or by using caml xml
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="8425EAF8-6GBE-4698-83C7-831CA8614D6D"
Title="WebPart"
Description="Some description"
ImageUrl="GenericFeature.gif"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml" />
</ElementManifests>
</Feature>
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module
Name="WebPart"
List="113"
Url="_catalogs/wp"
RootWebOnly="TRUE">
<File Url="WebPart.dwp" Type="GhostableInLibrary" />
</Module>
</Elements>
Related
I am developing a sharepoint feature which takes a backup of the site at sitecollection level and at site level whenevar a user tries to delete the site. The feature is working fine without issues for the existing sitecollection and sites when the feature is activated.
To give more picture, i am taking backup through code in events SiteDeleting and WebDeleting events. This events are hooked up using FeatureActivated event. I understand this ensures the event are hooked only up for the existing sites because of my code(i am hooking SiteDeleting and WebDeleting events in FeatureActivated event). After the feature activated, if i create a new site collection/sites the feature is not working(i.e backup is not taken when deleting the site).
I was trying to activate the event for new sites and hence i looked if there will be similar events like sitecreating where i can again hook up the SiteDeleting and WebDeleting events for new sites. But i came to know after some reasearch that there is no sitecreating event which can be used. After bit of googling i found that it can be done through a feature called stapling where we need to create another feature that attaches this feature to the new sites through template name. I have tried installing both the feature(my original and stapling feature) but it never seems to be working...
I am very new to sharepoint development and its taking time for fixing it. It will great if someone can help me to make the feature to work for the new sites as well.. I believe i am doing something wrong in scope parameter of feature.xml..listed below the feature.xml contents.
****SiteDeletFeature (My original Feature)**
Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature Title="My SharePoint Delete Feature"
Scope ="WebApplication"
ActivateOnDefault="True"
Hidden="false"
Id="DA910034-F270-4932-90D0-05AE2EE13192"
xmlns="http://schemas.microsoft.com/sharepoint/"
ReceiverAssembly="My.Sharepoint.SiteDeleteFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=762e98b8afce5f9b"
ReceiverClass="My.Sharepoint.SiteDeleteFeature.DeleteFeatureCallOut">
<ElementManifests>
<ElementManifest Location="Elements.xml"/>
</ElementManifests>
</Feature>
SiteDeleteFeatureStapling
Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="D0495B32-9F78-4142-A456-48B3ECBFFD6C"
ActivateOnDefault="True"
Title="My SharePoint Delete Feature"
Description="My SharePoint Delete Feature"
Version="0.0.0.0"
Scope="Farm">
<ElementManifests>
<ElementManifest Location="FeatureStapling\FeatureStapling.xml" />
</ElementManifests>
</Feature>
FeatureStapling.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="STS#0" />
.
.
.//goes on, i have included all template names
<FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="MyCOMMUNITY" />
</Elements>
I have tried various option in Scope parameter for SiteDeleteFeatureStapling like Web,Site but nothing worked out...
Could some one help me to fix this issue...Thanks in advance!
Regards
Bala
FeatureStapling.xml must have scope = "Farm"
SiteDeletFeature must have scope = "Web"
I need to create a web part page to be used in a SharePoint collection site. Any ideas?
Start with this walk-through:
http://msdn.microsoft.com/en-us/library/ee231546(v=VS.100).aspx
A good overview of developing for SharePoint:
http://msdn.microsoft.com/en-us/library/ee231517(v=VS.100).aspx
Update:
My mistake. Have a look at this post, Adding web page to blank sharepoint site definition it is still relevant for SharePoint 2010. The main difference is that visual studio will take care of creating a number of the files for you (feature, etc). Start by adding a SharePoint 2010 module to your SharePoint project. Part of the module will be a Sample.txt file. Delete this file and add the WebPartPage.aspx from the post I mention. Next edit the elements.xml file to reflect an appropriate name for you module. Then ensure this module is included in one of your features and you should have a simple web part page available to you once the feature is activated
I usually copy default.aspx from 12\TEMPLATE\SiteTemplates\sts into a custom Feature. I can then customize the page if I need different Web Part Zone configurations.
Feature.xml:
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="A94D977C-1F3B-4488-9DD5-88E0A03506B0"
Title="My Sample WebPart Page Feature"
Description=""
Scope="Web"
DefaultResourceFile="core"
Hidden="TRUE"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Modules.xml" />
<ElementFile Location="Files/default.aspx" />
</ElementManifests>
</Feature>
Modules.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="WebPartPage" Url="" Path="Files">
<File Url="MyPage.aspx" Path="default.aspx">
<View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Right" WebPartOrder="1"/>
</File>
</Module>
</Elements>
I have a custom MOSS publishing site collection / sites which have been provisioned with the following site definition properties within ONET.XML.
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="SimplePublishing" Value="false"/>
...
<Property Key="VersioningOnDocuments" Value="Major"/>
</Properties>
Is it possible to access/update these properties through the API such that, for example, all newly created document libraries have major/minor versions?
I'd like to do something like this:
PublishingWeb.Properties["VersioningOnDocuments"] = VersioningSettings.MajorAndMinor;
I haven't had any luck so far determining where these properties are stored.
Thanks.
The properties that you see like <Property Key="VersioningOnDocuments" Value="Major"/> are used by the feature or Provisioning Engine at the time of creation of the Site.
The only way to change them is to edit the onet.xml and you are forbidden to do so if it is a Out of the Box Onet.xml that came along the SharePoint Installation.
To Solve your requirement you can take this way
Make a copy of the Custom Site Definition and Edit the onet.xml of the new Custom Site Definition.
Create a Feature Handler that will change the versioning setting and Staple the Feature to the Site Definition you are Interested in.
I have developed an event handler,called TaskListEventHandler, for the Task list ((ItemAdding, ItemDeleting, ItemUpdating) as feasture using the WSP Builder project template, and I have also added a web part, called RegisterEventHandler, which will be used to bind(register) the events to a list. The webpart is WSP Builder template "Webpart without feature".
Currently, on deployment, my feature and the webpart is getting deployed sucessfully. The web part is also available in the web part gallery.
Now i need to make the web part available in a particular category/group in the gallery using the WSP Builder?
I tried setting the group in the RegisterEventHandler.webpart file (which is automatically created by WSP builder on adding the webpart template inot the project), but still it doesn't show up :(
Cannot import RegisterEventHandler Web Part.
RegisterEventHandler
This webpart is used to register or unregister the event handler to the task list - By Biju (09 Sep 2009)
Biju Webparts
Could anyone please help or suggest me some solution or sample code?
Like Per says.. if you add a webpart feature with wspbuilder it will give you an elements.xml file. This contains an entry like this:
<File Url="WPName.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="MyGroup" />
<Property Name="QuickAddGroups" Value="QuickGroup" />
</File>
Where the properties determine what group is used in the library. Mind you if this web part is already activated in your site re-activating it again wil often not overwrite the existing registration; you'll have to delete the .webpart file from the web part library first.
The category/group of a web part is specified in the elements.xml file (Groups property).
But as Janis comments it seems a little odd to add a web part to add a EventHandler.
If you just want to add the eventhandler to all tasklists on the site where you activate the feature then you can do the add in elements.xml directly.
If you want to add it to a special task list then you can do it in an FeatureReceiver.
If you want to give the enduser the option of selecting which list to add it to then a the web part might be ok, but an application page would probably be a more "SharePoint" way of doing it, or use SPEvent Handler Manager from codeplex
I have a project that's built on SharePoint Smart Templates.
I don't have a web part, so I deleted the cs file.
Instead all I have is a blank feature.
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{6447a5a5-c6c7-4aee-b7c5-b7417e30c03f}"
Title="My Content Types"
Description="Contains the Content Types used by My Provided Applications"
Scope="Site"
>
<ElementManifests>
<ElementManifest Location="Manifest.xml"/>
</ElementManifests>
</Feature>
Any idea why this feature won't install?
update
I manually installed the feature using straight copy and stsadm - this worked, so its not the feature code in question, rather the project could be "whacked"
This feature is scoped at site level. Try to see if you have it in Site Settings -> Site Collection Administration -> Site Collection Features.
I just did away with smart templates, obviously I am not smart enough to use them, and have reverted back to normal WSP Builder, and its working great.