taclejj

Is there any event in c# to know whe a new site is created

What i need it to chage the owner and permissions for every MySite as soons as it has being created, is there any event or feature or any thing that make this posible, I have been trying to add a feature and when I activate manually it works, but I need to activate any time a MySite is creat.



Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

Ishai Sagi

The answer is "No".

you can only trap events for a web site

  • Deleted, Deleting
  • Moved, Moving

and for a site collection only

  • Deleted, Deleting





Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

JonasObe

You could make use of a feature that gets activated in the site definition and then write your code in the feature receiver.



Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

taclejj

Thank you JonasObe, this is the aproach I have been working on, but now I have a problem, I need that this feature is activate when the site "MySite" is crated to modify the properties of this site, and now is working if I activate manually.

How can I activate a feature when this site is created





Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

taclejj

Thanks Ishai this was my first aproache but I realize that this is not the way I should continue, there are no event for what I need, but thank you very much.





Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

JonasObe

You could create a Feature/site template association http://msdn2.microsoft.com/en-us/library/aa544294.aspx that points on the My Site definition.



Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

Ram Chenna

hi

you can create a Feature Receiver class library code and create a feature that would activate when the site gets created from the site definition.

Activate the Feature in the site defintion as a <WebFeature> and write code to change the owner/user or rights whatever you would like to do in the FeatureActivated Event.

Ram






Re: SharePoint - Development and Programming sharepoint 2007 how to know when a new site is created

MVM7

By using the featuere it will work fine. By using EventReceiver we can create like this some sample code goes here.

public class CancelAnnouncementDeleteHandler : SPItemEventReceiver

{

public override void ItemDeleting(SPItemEventProperties properties)

{

string HandledMessage = ("Announcements can not be deleted from this list");

properties.ErrorMessage = HandledMessage;

properties.Cancel = true;

}

}

By creating the solution also we can create. if you required about solution let me know.

Thanks

Mohan