Sharepoint 2010: Web parts inside web templates - visual-studio-2010

I created a site in Sharepoint 2010 and exported it using "Save as template". That created a .wsp which I imported into Visual Studio 2010 and created a solution. That solution contains a web template (which is just an onet.xml file) among all the site pages and assets. So far, so good.
Now, I developed some web parts and added them to the project. Then I compiled and packaged everything, created a site in Sharepoint by selecting "Select template later", uploaded the .wsp into the site, and activated it. At that point all the webparts are created, and also the web template. So I go to the home page, and create the site with that template. But when the site is create from the template, all the web parts are deleted and replaced by Sharepoint basic web parts (Content editor, page viewer, ...).
Is there a way to include the web parts in the web template? I'm sure it's possible editing the onet.xml, but I'm not sure how.
Thanks in advance

Have you tried manually setting up your web part page after the deployment? Then you can export the site as a template and then look at the resulting onet.xml file. That should give you some clues about the changes you need to make.

Related

Pulling the HTML from a DNN site I created

Is there a way to see the HTML for each page of a DNN site I created? I need to insert this code into a project within Visual Studio 2017. Is there a good approach for this?

How can you add a transform in a visual studio web project?

I've created a new ASP.NET web project, that doesn't have a *.csproj file, but rather needs a website.publishproj to be published. The default project has a Web.Debug.config file that can be used for transforms.
How can I create a Web.Release.config, assuming I created a Configuration for it already?
Note: When I try to do it manually, it fails to get indented, and more importantly it fails to transform.
You mean ASP.NET web site and not project. The web site is the one without the .csproj file, csproj stands for c sharp project.
I have played around with this and it is not possible. There is no configuration on this in the solution and no project file (csproj) that contains meta data on the file structure including how files should be associated. The presentation in Visual Studio for a web site "project" (here I mean project as in a node under the solution) simply lists all the content (files) in a specific folder. If you were to add a new file in the folder from the File Explorer and then hit refresh it would be added to the list. Similarly if you delete the Web.Debug.config file and hit refresh it is removed but after you add it again manually using File Explorer and hit Refresh in the project it will be re-added but again as a "child" of Web.config. This is likely because it does not appear to be possible to specify a different build configuration in the solution for a web site other than debug and there is no way I can see adding a configuration to a web site as there is no meta-data for the site.
So I am afraid that this presentation is not possible in a web site in Visual Studio. It could be accomplished by using a web project (with .csrproj) but that is not what you asked for.

Sharepoint 2010 Create and Add Webpart Automatically In Sharepoint Site When Deploy WSP

I'm using SharePoint 2010 and I have developed webparts at visual studio 2010. I'm already using WSP to deploy my web application into server, but still should create and add the webpart manually through SharePoint site. Is there any way that we can deploy the application and automatically create and add all webparts into the site?
Generally web parts are added to pages using features. Basically you create one site collection feature to deploy web part files to web part gallery and web scope feature which adds this web parts to pages (for example default site page).

Sharepoint 2010 build solution with UI then export as wsp template, to deploy in new environment

I build up a solution using UI in Sharepoint 2010. Solution consisted in creating a new site, as subsite using Team Site Template. Then I added the following artifacts:
Several Custom Columns
2 Custom content types using above columns
Document Library using my content types above
Several Custom Views created for above Document Library
1 Reuseable Workflow (this was developed with sharepoint designer 2010)
3 List Worklfow, using 'Three-state-workflow' template
Customisation of site navigation (quick launch)
Customisation of site home page
Some security groups
Added users to groups
Then I exported the site as wsp template, downloaded it to local drive.
I imported it in visual studio 2010, than changed the deployement method to 'Farm Solution' (not Sandboxed Solution) and packaged it.
I have to deploy to new sharepoint environment (new server), but till now there are issues in feature activation (total 5 features). the feature wich contains module elements is having issue.
Any idea how to solve this issue ?
Any idea how to streamline this process in order to avoid deployment issues ?

Web Application within a Web Site in Visual Studio?

Visual Studio allows you to make "Web Sites" and "Web Applications", but, inside a project, can you have one within the other?
Say I have my website "www.mysite.com" and I have an application called "BudgetCalculator". One the production server, this is supposed to be located at:
www.mysite.com/BudgetCalculator
And the BudgetCalculator app contains links back to other parts of the website, like "/page1" and "/page2".
However in Visual Studio, when they're listed as two different projects, they're on the same level. When I fire up the debugger for the BudgetCalculator app, those links aren't going to point back to the main website, like they should.
Is there a way around this?
One solution would be to stop using the built-in .NET Web Server.
Use IIS, create one site, and make your Web App a Virtual Directory inside of the Web Site.
A project cannot host/contain another project in Visual Studio.
You can however create a project that sites in the directory of another higher level project when you create it, however they may not be directly linked, so you couldn't debug them both at the same time.

Resources