Using Visual Studio to create code pages without aspx

I want to create my own “code behind” as pages, so that I can have HTML in the HTML file and code in the cs file, but be able to have Intellesense for tokens in the HTML file. (I know what the .NET page class does, but I want to have something much easier)

EG: in the .html file:

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

and in the .cs file

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

So my question is how to make the HTMLSnippet class so that its members are automatically created and, in particular, displayed in Intellesense, as I add tokens to the .html file?

, .net , designer.cs , , , , Intellesense. !

, , HTML- . . , VS, , .html, .cs .

+3
5

-, ASPX , . , @Page. viewstate, , .

, ASP.NET MVC. , RTM MIX, Microsoft . , RC2, RTM . ASP.NET MVC ASPX , .

-, , , HTTP . .htm .html, , .html , . , .

, Intellisense. - , Stagner: http://weblogs.asp.net/joestagner/archive/2008/05/12/add-custom-javascript-intellisense.aspx

, . XSD (XML), ala: http://vyasashutosh.blogspot.com/2007/05/providing-custom-intellisense-in-vsnet.html

ASPX , . , , . @page, , , ASP.NET - , .

+2

, , , .

:

protected string myVar1 = "Hello World"

Html:

<html>
   <body>
     <div><%= myVar1 %>
   </body>
</html>

, , , .

+1

MVC framework.

else PHP, DJANGO, ROR , .

+1

, UI.TemplateControl, . , , , , , , .

0

asp.net, script xml markup IE

<% foreach( string key in collectionOfItems.Keys ) %>
<div><% =key %></div>
<% } %>

-

<foreachcollectionOfItems.Keys >
<div>$key</div>
</foreach>

, , . google it... spark

0

Source: https://habr.com/ru/post/1704455/


All Articles