Share via


.aspx '.designer.vb' file not showing up as child of .aspx page in 'Solution Explorer'

Question

Wednesday, April 22, 2009 9:07 AM

When I view my .aspx pages in solution explorer, it has a tree view to expand and collapse elements.  With a .aspx page in solution explorer, expanding it will then show that there are (2) associated files:  Default.aspx.vb and Default.aspx.designer.vb.

Something unusual is happening in my project where the .vb code behind file shows up as a child element of the .aspx page, but the deisgner.vb file does not. The designer.vb file is up one level in the same directory as the .aspx page. This is not causing any issues with the app by the way; it runs just fine.  Aslo, dragging the designer.vb file does nothing as VS.NET states they are already in the same directory.

I am wondering why the designer file is not in the proper hierarchy in the tree under the .aspx page.  Does anyone know why this is happening?

Thanks! [*-)]

All replies (3)

Tuesday, December 1, 2009 11:59 AM âś…Answered

Well I came up with a solution that does work even if it is a bit brute.  This works best if the '.designer.vb' file has never been modified manually and just was the code that was auto generated.  If you modified it, you may want to copy all of the code out as well into a file as described below.

  1. Back up all of your .aspx pages before proceeding (SourceSafe, TFS, .zip, copy and paste, whatever) in case you need to revert back.
  2. Copy all of the .aspx source into something like notepad.  Just do a Ctrl+A on the keyboard and copy and paste it all.
  3. Copy all of the .vb or .cs code behind into a file as well like notepad.
  4. Delete the .aspx, aspx.vb (or .cs), and .aspx.designer.vb (or .cs) files from solution explorer.  This will permanently delete the entire page (hence step #1 in case we messed up we can go to a backup copy).
  5. Add a new item to the project of the same type .aspx page (master, content, traditional, etc.) as before using the exact same name.  (This is important for the code we copied out earlier to work).
  6. Paste back in all of the .aspx source overwriting anything already auto generated.  Don't try to inject the old code.  Simply copy it all back into your page.
  7. Paste in all of the code behind .vb or .cs into the class behind the page.  Same as before, overwrite the entire file.
  8. Save and re-build the solution 1 page at a time.

It worked perfectly for me on about 15+ pages with no issue.  The only exception would be if you had manually modified the .designer auto generated file.  The new file would not have your changes, so if you modified anything follow the copy and paste steps as well.

When I was done, all the new pages were back in the proper structure within Solution Explorer.  Overall, we basically just deleted the old page and created a new one with the same code and design.  If you have a ton of pages you might be looking for a faster way, which I do not know and nobody replied with any other solutions.  My suggestion is to just take a few hours blocked off and go through this process.  It is so much nicer not to have all of the files out of order in the tree, and have everything collapsible again as it should be.

Hope this helps!


Friday, May 8, 2009 11:12 AM

This just happened to me as well this morning.  Have you found a solution??


Friday, May 8, 2009 2:02 PM

No net yet. Still waiting on some feedback.  Project still runs fine, just the solution explorer tree is messed up.