Creating a new Website dynamically in SharePoint using Visual Studio

31 03 2010
Hiya,
Here is a small sample code which creates a new website dynamically (during execution) in SharePoint. I put this down because I myself had a lot of problems searching for this excerpt on the net. Hope this post helps reduce the effort by others in the future. The sample code is as follows:
SPSite _portalSite = new SPSite(“http://localhost”);     //localhost is your main parent site.
_portalSite.AllWebs.Add(webUrl);    //webUrl is a string that serves as the Url path for the website being created. Here webUrl = “ShivaSite”;
SPControl.SetContextSite(System.Web.HttpContext.Current, this._portalSite);    //Setting the context to the main parent Site.
this._newSite = SPControl.GetContextWeb(System.Web.HttpContext.Current).Webs[webUrl];
//getting the Context for site created. We need this to set the main intricate properties of the Website that is created.
this._newSite.Title = webTitle;
this._newSite.Description = webDescription;
this._newSite.ApplyWebTemplate(SPWebTemplate.WebTemplateSTS);
this._newSite.Locale = culture;     //culture is as System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(“en-us”);
this._newSite.Update();   // We must update the Site.
this._newSite.QuickLaunchEnabled = true;    //enables the site to be available at QuickLaunch.
There are other overloaded functions for the AllWebs.Add() which include all the properties as arguments. The details for that may be found in the MSDN library available online.





Custom Workflows in MS Sharepoint

31 03 2010

There are several ways in which we can develop custom workflows in SharePoint.

  • using SharePoint Designer, or by
  • using Visual Studio.

I here try to develop a custom approval workflow using Visual Studio 2008. If there is anyone, who wishes to know more on it, they are welcome to contact me, or leave a comment and their email, so that I can get back to them.

The Best place for beginners in SharePoint in Shelton’s Blog (http://www.sheltonblog.com)

Thx





My first Post..

31 03 2010

Hi ppl, this is my first post on wordpress. I ll be posting anythin and everythin that is up and runnin in my life including the technical stuff.

Presently I am undergoing an internship on Custom sharePoint Workflows with Force10 Networks Pvt. Ltd.

I ll post my proceedings in order. Ppl who go thru are free to post their comments and opinions..

Best regards,

Shiva