Why are code-behind files not visible in a VB.NET Web Application project?
I am trying to convert a VB.NET web site project to a web application project, yet the in web application project, my code-behind files are not visible unless I set the solution explorer "show all files" opt开发者_开发百科ion. Why is this? What setting can I change so that my code behind files are always visible?
You can set VS to always show all files. That's the best soluution although a really ugly way to avoid this would be to rename the files for the code behind.
I know this is a bit of an old question, but it's the top result on Google and I found an alternate solution.
Open your .vbproj file for the project in a text editor, and search for your codebehind file's name. You'll find that it looks something like this:
<Compile Include="dashboard\index.aspx.vb">
<DependentUpon>index.aspx</DependentUpon>
<SubType>ASPXCodebehind</SubType>
</Compile>
If you simply remove the DependentUpon
tag, everything will still work properly, but both files will show up in Visual Studio, as desired. So my final version would look like this:
<Compile Include="search\index.aspx.vb">
<SubType>ASPXCodeBehind</SubType>
</Compile>
It takes a little bit of manual editing but it works for me. Alternatively if you manually rename/edit your files into a page/codebehind format after creating regular class files, they will appear as wanted in the project without having to resort to "Show All Files."
精彩评论