I got a file, let's call it MyPage.aspx. It has no codebehind and I need to add a codebehind file to it. Here's what I've done:
- created MyPage.aspx.cs and included it in the corresponding namespace
- Added the following code to the Page tag of MyPage.aspx: AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyApp.MyPage"
Still, it doesn't work. I cannot access runat=server elements from the codebehind. Strangely, I also noticed one more thing:
The definition of the class in MyPage.aspx.cs is as follows:
public partial class MyPage : System.Web.UI.Page
Normally, both words MyPage and Page in this line would be green. However, only the word MyPage is green and the word Page is still black.
I'm kinda stuck with this, any help would be appreciated.
Code Behindfile,RightClick on .aspx -> Select "Convert To Web Application" option.