I am using Visual Studio 2013. I am trying to add a attribute in the .proj file to a .js file entry, so that the designer places the file beneath the corresonding file page file. For example, the designer will display Test.aspx, and beneath it will have test.aspx.cs and test.aspx.js.
Now, I have done this in an older Visual Studio such as 2010. I am wondering why it is not correctly working in Visual Studio 2013? An example o the entry is below:
<Content Include="Agent\Scripts\AgencySettings.aspx.js">
<DependentUpon>Agent\Profile\AgencySettings.aspx</DependentUpon>
</Content>
I do not see what I am doing incorrectly at the moment. Any help would be appreciated. Thanks!
I figured out the issue. For some reason if the file does not sit in the same directory, it cannot be nested to it. So, I had to move the .js file to be in the same directory as the .aspx file I wanted it to be nested with. That sucks, as I had done this before in prior visual studios, and was able to keep all script files in the scripts directory, but display them in the designer differently. Anyways, that change was the solution and here is the code entry for it:
<Content Include="Agent\Profile\AgencySettings.aspx.js">
<DependentUpon>AgencySettings.aspx</DependentUpon>
</Content>
The designer now shows the following files when looking at AgencySettings.aspx and expanding the file:
AgencSettings.aspx
-- agencySettings.aspx.cs
-- agencySettings.aspx.js
Related
I'm using T4 templates to automate creation of Poco objects. Ideally, these templates will run against multiple databases and will generate files going into separate folders based on where they came from. I already have the folder included in the project, is there anyway to add these generated files programmatically without knowing the names in advance?
After some more searching, I came across this answer which lead to me finding ProjectItems.AddFromDirectory , MSDN source here, which solved my question!
In Visual Studio, unload your project, then right click on it and edit the csprojfile.
You should be able to do something like this:
<ItemGroup>
<Compile Include="PlanExtract\*.cs" />
</ItemGroup>
Assuming that your generated files have a .cs extension.
Reload your project, then you should see the added files appear.
I'm using Visual Studio Community 2015 and need to view the designer.cs file for one of my webforms. However, when I expand the aspx file in the solution explorer, it does not show up. How do I force Visual Studio to show me the designer.cs file?
Here's what I see in Solution Explorer:
Also, I seem unable to edit the project file (.csproj) by hand so that it will show the designer.cs file because I can't find the project file in the folder containing the code. Here's a screenshot of that folder:
Folder Contents
In order for a designer file to show up beneath a source code file within the Project Explorer, the project file (.csproj) must have an entry as follows:
<Compile Include="page.aspx.cs">
<DependentUpon>page.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="page.aspx.designer.cs">
<DependentUpon>page.aspx</DependentUpon>
</Compile>
Please open your ProjectName.csproj file and check to see that this pattern exists for your source file (.cs) and designer source file (.designer.cs).
You will have to unload and then reload your project from Visual Studio for changes to the Project File to take effect.
Per Dave in the comments above - It appears that your project is configured as a web site instead of a web application. I would recommend that you convert your project to a web application by creating a new project and re-adding the files. You can read up on the differences between the two models here on MSDN
I'm trying to create a Visual Studio 2013 custom project template that creates multiple projects. I'm having an issue because one of the projects has a glob include path to the other:
<Content Include="..\Project1\Content\**\*.*">
<Link>Content\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Content>
The wizard to create the project seems to go through the path piece by piece (.., Project1, Content, **, .) and tries to create a file on disk. The problem is that '*' is an invalid file character.
Is there any way to accomplish this? Do I need to remove this from my template CSPROJ file and manually add it in the template wizard?
EDIT:
There seems to be a visual (?) bug in visual studio. When I opened my website folder as a website and looked at my Views.ascx.designer.cs it doesn't show that it is associated. However, if I open that same website's solution file then the files are associated and all is well.
Just to be clear, even though it is still showing the below error messages it is working and I believe that it's a bug with opening it as a website instead of as a solution.
On my live site I have an error:
But it should exist because I have it in my Views.ascx.designer.cs:
But in Visual Studio my Views.ascx.designer.cs is not being associated with my View.ascx:
I tried to drag and drop the .designer file onto View.ascx but it displayed this error message:
It works and looks perfectly fine on my dev server:
I'm not sure how I would go about getting the file to associate itself with the View.ascx or View.ascx.cs files.
First step: right-click the files and exclude them, and try including them back in. It may fix itself. If not, you could edit the project directly; you just to add the dependency that the CSPROJ or VBPROJ expects. Here is an example that you need to make sure is in the project XML:
<Compile Include="Views\Main.aspx.designer.vb">
<DependentUpon>Main.aspx</DependentUpon>
</Compile>
<Compile Include="Views\Main.aspx.vb">
<DependentUpon>Main.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
Have had the same issue while adding form from other project to the pending one , I've excluded both files then added back by adding non-designer file 1st and .Designer.cs was then added in the right place automatically from the same catalogue as .cs file (VS2012).
Whenever I open an existing project in VS 2005, the designer.cs files do not show up under .aspx files, and due to this when I add controls in .aspx the designer.cs is not updated.
Below is how the structure looks:
+----AAAConfirm.aspx
. .
. ..AAAConfirm.aspx.cs
.
.----AAAConfirm.aspx.designer.cs
You need to "show all files" for the project, it most likely got removed from the project file by accident. When you see the file in Visual Studio, right click the file and select "Add to Project".
Or
Check the project file and make sure the designer file's compile tag has a child element called DependentUpon
The XML section specifying the file's inclusion in the project should look something like this
<Compile Include="AAAConfirm.aspx.designer.cs">
<DependentUpon>AAAConfirm.aspx</DependentUpon>
</Compile>
Also check that the markup page AAAConfirm.aspx has the correct codebehind and inherit reference in the <%Page> tag. Did you maybe change namespaces? Try setting the Inherits attribute value to the class name without the namespace.
Copy your project to some other folder and
Locate the corrupted aspx.designer.cs file through the Solution
Explorer Delete only the designer.cs file from your project
Rightclick your main aspx file and select “Convert to Web
Application“.
Ref : Tip: regenerate aspx.designer.cs files when corrupted