PDA

View Full Version : How to generate .cs from .aspx?


Nelson9
10-13-2009, 02:23 PM
I created new website I had unchecked "Place code in seperate file "

Now I have code within .aspx pages .
I want to generate .cs from for this website.
Can anyone help me out?

Mike_O
10-20-2009, 06:01 PM
Hey Nelson9,

1. Create a separate CS file for every ASPX page you have, and give each one the same name as the associated ASPX file + ".CS". For example, if you have file "MyFile.aspx", you will create file "MyFile.aspx.cs".

2. Once you have your CS file(s), create your class(es) inside and transfer all the server-side code from your ASPX page(s)

3. Back in your ASPX page(s), where you have <%@ Page....%>, add the following attributes:
...CodeFile="[Your file name].aspx.cs" Inherits="[Your class name]"...

Regards,
Mike