It might be that the only thing you want to do with a single-file Web Forms page in Visual Studio is to convert it to a code-behind Web Forms page. Using Visual Studio to convert a single-file page to a code-behind page automatically accomplishes the following:
1. Generates a code-behind class file for the page.
2. Adds the appropriate page directives to the page so it is linked with the code-behind file.
The conversion does not do the following:
a. Convert inline code to code in the class file.
To convert a single-file .aspx page to code-behind
1. Open an existing project, or create a new ASP.NET Web application.
2. On the Project menu, click Add Existing Item.
3. Browse to the .aspx page that you want to convert.
4. Click Open. Visual Studio will display the following message:
There is no class file in the project associated with the Web Form '
5. Click Yes. Visual Studio will create the code-behind file and link it to the .aspx page.
6. Click the Show All Files button in Solution Explorer, and expand the tree below your newly converted file to see the code-behind class file.
7. Open the new .aspx file.
8. In HTML view, inspect the file to make sure it contains an @ Page directive at the top that contains the CodeBehind attribute.
9. Inspect the file to make sure it contains an HTML
2 comments:
I don't think this works for 2010.
Post a Comment