I just inherited a web site that was created by a designer. The site was originally created with all *.html files. The designer renamed all the *.html files to *.aspx files. Hence there are no aspx.cs files created. I pulled the site into a new VS2012 solution. My question is, is there a way in VS 2010 to automatically create the code behind files for a an existing stand alone aspx file?
Create code behind file after aspx has been created
asp.netvisual studio 2010
Related Topic
- C# – The breakpoint will not currently be hit. No symbols have been loaded for this document in a Silverlight application
- C# – Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated
- C# – Where’s the code-behind for sharepoint aspx pages
- C# – ASPX can’t seem to find the code behind files
Best Answer
I don't know of an automated way to do this, but if there is no server side code in the existing *.aspx files then it should just be a case of adding the .cs codebehind files and then wiring them up in the
<%@ Page
tag like so:Note: This will not create the
YourPage.aspx.designer.cs
file. (I usually delete these anyway as they cause merge issues - i find it easier to add the controls i need to reference to my code-behind file manually.)The other alternative is to just create a new "Web Form" for each page with the correct names and then copy and paste the existing markup into them. If you do have server code in the existing *.aspx files then you will need to manually copy it to the code-behind.