Using Visual Studio to make non aspx code-behind pages

Posted by rizzle on Stack Overflow See other posts from Stack Overflow or by rizzle
Published on 2009-03-09T16:57:28Z Indexed on 2010/06/14 22:32 UTC
Read the original article Hit count: 134

Filed under:
|
|
|

I want to build my own "code behind" like pages so that i can have HTML in a HTML file and code in cs file but be able to have Intellesense for the tokens in the HTML file. (i know that's what the .NET page class does, but i want to have something much lighter)

EG: in the .html file:

<%@ Directive classname="HTMLSnippet" %>
<html>
   <body>
     <div>[%message%]
   </body>
</html>

and in a .cs file

public class MyClass : HTMLSnippet
{
   public class MyClass () {
      snippet.message = "message goes here"
   }
}

So my question is how do make the HTMLSnippet class so that it's members are automatically created, and specifically show up in Intellesense as i add tokens to the .html file?

I know that .net currently does it by creating the designer.cs file and basically builds a class with all the elements from the page as it goes, and that would work fine but how can i get visual studio to generate that before compiling so that it shows up in Intellesense. Thanks!

Clarification I'm not using this as a handler yet, i want to use this to have HTML snippets with tokens be usable in code as an object with properties. so almost like a custom control. I think what i have to do is create a VS add-in that waits for me to type tokens into an .html file then it automatically creates a .cs file with members for each token.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET