I want to use code beside files for my views in my ASP.NET MVC project. Is there any simple way in Visual Studion 2008 how to add a code beside file to the view?
Note: I know that code besides files are no preferred in ASP.NET MVC but my reason is that I want to give .aspx files to designer and don’t want to confuse him nonHTML code as little as possible. More good reasons for doing that can be found here.
Add a class to your view folder and name it (for example) Foo and make sure that this class inherits ViewPage or ViewPage in case if your View is a strongly typed one.
Then in the aspx markup change the inherits from attribute of the @page directive to Foo.cs
Hope this helps.