Converted Web Site Project to Web Application Project - Can not access UI Controls - visual-studio-2012

I have converted a large project, currently in VS 2012 from a Web Site project to a Web Application project.
I have added the namespace to all of my .cs files.
I have ran the "Convert to web application" on the project and it has generated all of the needed files. (So I do have the designer files created as part of this upgrade)
When I compile, it errors off on all of the references in my C# code behind file for all of the UI Controls. The error indicates that the control does not exist. The controls are there, and they are present in the designer files.
I have cleaned my solution and no matter what I do I get this error.
Any ideas / suggestions of things to try? Have I missed something in the conversion to a Web Application?

Fixed My Issue.. It was the inherits statement in the ASPX. I had to include the namespace along with that... Problem solved... so, the syntax is inherits="namespace.formname"

Related

Issue related to layout of custom webpart

According to requirement of application, I have developed a custom web part in Kentico 9. This web part is using with same functionality at various places but we have to use with different layout structure.
As per my understanding, we can create custom layouts for a single web part from "Layout Tab" in web part configuration. As I used same things with various Kentio built in web part like Logon form, Logon-Mini form, etc.
But while trying to create new layout for my custom web part, I am getting web part loading error and when I checked into event log it is showing following error:
The file
'/CMSVirtualFiles/WebPartLayouts/=vg=87a868ce-926c-4cb3-a441-b4f1d4310afc/TDNForgottenPassword/ForgottenPassword.ascx.cs'
does not exist.
Here, internally system looking for ".CS" file under "CMSVirtualFiles" folder, which has actually under the "CMSWebParts" directory in which I have created my user control.
Is there any specific configuration required in custom web part to implement multiple layout of it? Please help me and guide me, what am I missing or doing wrong?
Check your webpart code file property in the ascx file. You need to specifically declare the full relative path to the .cs file and not just the filename. For example:
Correct
CodeFile="~/CMSWebParts/Community/GroupRegistration.ascx.cs"
Incorrect
CodeFile="GroupRegistration.ascx.cs"
Please make sure you don't have the store virtual files in the file system setting enabled.

SPSolution Pages: Where are they found?

I am currently training on sharepoint and have few weeks experice with regards to development in sharepoint. My current task involves deploying a .wsp solution on a server farm, and did that using the powershell through the Add-SPSolution, Install-SPSolution, and did that successfully. The problem I am encountering is that in the spsolution I had a webpage named TestPage.aspx, I cant find where the page is residing such that I can access it. there a specific place where the page resides or any command which I can use?
Visual Studio usually creates a folder for application pages, so you may try:
http://server/site/_layouts/foldername/TestPage.aspx
where foldername is the name of your project/solution.
If you get "The resource cannot be found" - HTML 404 error, the site is not there.
Otherwise, even if it says "An Unexpected error has occurred" it does not mean the site is not there.
The site may exist, but has some errors. In that case the best way would be to check Windows Event Viewer and logs.
You cannot just add an aspx file and deploy on sharepoint.
Maybe what you are after is how to deploy an application page, an application page sits at the application level, so every site collection will be able to access it.
How to deploy an application page:
To add an application page do the following:
create a new empty sharepoint project
add "Sharepoint "Layouts" Mapped Folder to the project
in layouts folder create a folder (usually the name of the project)
add an application page to that folder.
that application uses sharepoint masterpage, put some content in.
Deploy using visual studio or compile and deploy the wsp using the method above
access the page in /_layouts/foldernamed/test.aspx*
If you are looking only to add some content to a sharepoint page, then I suggest you use a visual web control. it is basically a user control wrapped in a webpart. After deployed you can add it to a webpart page that you can create using the Sharepoint UI.

Deploying custom dll's in SharePoint 2010

I'm new to SharePoint and trying to get my head around this. I have a simple Web Part project. I also have a custom Data layer project that uses the Microsoft Enterprise Library for data access. In the Web Part project, I am adding a reference to the Data layer project's assembly. I specified in the Package of the Web Part project that I want my Data layer's assembly to be deployed. I can verify this works by using standard ADO.NET classes and not the custom MS library. If I deploy to the SharePoint server (which I have 100% access to) using the Enterprise Library, I get the error message:
"Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data"
What steps do I need to take to ensure this project and all future projects on the server can easily gain access to the Enterprise Library for data access?
Thanks!
You did everything correct until a certain point: Deployment.
When deploying external DLLs, which shall also be put into the GAC or somewhere else, you need to package them with the WSP aswell. This has become very easy with Visual Studio 2010:
Open your Package
Click on "Advanced" (on the bottom)
Add your external DLL and maybe even SafeControls for the web.config

SharePoint 2010 VS development: Intellisense for ASPX files

I'm using Visual Studio 2010 to develop a SharePoint Server 2010 solution. Part of this includes custom Page Layouts, but when editing them, intellisense is completely broken, since Visual Studio doesn't appear to know how to handle them. Here's what I've done:
Created a new blank solution
Right-clicked on the solution and created a new "Empty SharePoint Project"
Right-clicked on the project and created a new "Module"
Renamed sample.txt to MyPageLayout.aspx or created a new ASPX Web Form
At this point, intellisense for the new Page Layout is broken. It gets even worse with tools like ReSharper installed. Also, things like "Format Document" will break the Page Layout (by for example changing asp:Content to asp:content)
What I've tried to get intellisense working:
Added a Web.config from a standard Web Application Project to the root of the SharePoint Project - made no difference.
Added the ProjectGuid for a Web Application Project to the SharePoint project file - broke the project.
Is there any way to get intellisense, and the rest of the support Visual Studio can offer for Web Forms, available when developing SharePoint 2010 Page Layouts?
I have followed your post to some extent.
Using VS2010 (On an x64 machine)
Create a blank SharePoint solution. (this properly combines your #1 & #2)
Add a module (in SharePoint a module is like a folder or resource container)
added a new class to the module (intellisense present)
Added a new webpart to the module (intellisense present)
added a user control to the project designer works and (intellisense present)
I believe that you should consider creating true server or visual web parts. This will have a harder learning curve but will pay with dividends in the future. You will be able to package and deploy your solution again or to another server/farm. Aspx pages can be added and manipulated by the dreaded SharePoint designer. In 2010 the theory is that those designer mods can be packaged and deployed.
I work in this environment every day and the best advice I can give is to embrace the SP object model and do 'it' the sharepoint way. Don't try to force SP to be something its not. :)
This is probably not the solution you are looking for but it's the best thing I found for SharePoint development.
In your solution, create 2 projects :
1 SharePoint Project (empty or not)
1 ASP.NET web application project
Develop all your UI (aspx pages, ascx controls, etc.) in your ASP.NET project and create post-build steps that will copy the pages and controls to the appropriate folders in your SharePoint solution.
That way, you will benefit from all the features of web development in visual studio and it will be very easy to deploy as well. It is a bit of a time investment at first, but it is well worth it if you have any considerable amount of logic to implement in your aspx pages.
This blog post documents what you need to do.
you can add an intellsense to pagelayouts by closing the page and simply reopen it from
file->openfile->your file page layout path
Or you can directly "Right Click" on the file you want to open from the Solution explorer and then select "Open" : you'll get the Intellisense !

How to get a product key token from a library file programatically?

I am creating a SharePoint solution project that will install the Telerik dll files into the GAC and write the appropriate lines into the webconfig upon feature activation. My question is, is there a way to get the product key token, version, and culture info of a dll programatically. I have used the System.Reflection.Assembly.GetExecutingAssembly() before to get the embedded resources, such as a javascript file, and add it to the appropriate folder. Would this be the same way to get the dll file, and if so what would I do to get the assembly info of an embedded assembly? Thanks for any direction.
See this related question.
Out of curiosity, where in your web.config are you adding references to Telerik DLLs? I recently did a project that uses the Telerik Silverlight controls. While I had to configure the web.config to support the .Net 3.5 framework, I did not have to add anything specifically for the Telerik DLLs as their controls were all wrapped within my custom Web Parts.

Resources