{"id":671,"date":"2018-04-10T15:31:00","date_gmt":"2018-04-10T14:31:00","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=671"},"modified":"2020-04-10T15:57:21","modified_gmt":"2020-04-10T14:57:21","slug":"convert-a-code-behind-aspx-to-an-inline-aspx-page","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/convert-a-code-behind-aspx-to-an-inline-aspx-page\/","title":{"rendered":"Convert a code-behind ASPX to an inline ASPX page:"},"content":{"rendered":"\n<p>To convert a code-behind ASPX to an inline ASPX page:<\/p>\n\n\n\n<p>1. Modify Page directive to read<\/p>\n\n\n\n<p>&lt;%@ Page Language=&#8221;cs&#8221; Strict=&#8221;True&#8221; %&gt;<\/p>\n\n\n\n<p>2. Paste code into into script tag in the header<\/p>\n\n\n\n<p>&lt;HEAD&gt;<br>&lt;SCRIPT language=&#8221;cs&#8221; runat=&#8221;server&#8221;&gt;<\/p>\n\n\n\n<p>.. your code goes here ..<\/p>\n\n\n\n<p>&lt;\/SCRIPT&gt;<br>&lt;\/HEAD&gt;<\/p>\n\n\n\n<p>only paste the code INSIDE the page class, under the &#8221; Web Form Designer Generated Code &#8221; section. Don&#8217;t paste the class itself!<\/p>\n\n\n\n<p>3. Add any namespace imports at the top:<\/p>\n\n\n\n<p>&lt;%@ Import Namespace=&#8221;System.IO&#8221; %&gt;<br>&lt;%@ Import Namespace=&#8221;System.Text&#8221; %&gt;<br>&lt;%@ Import Namespace=&#8221;System.Text.RegularExpressions&#8221; %&gt;<br>&lt;%@ Import Namespace=&#8221;System.Configuration&#8221; %&gt;<br>.. etc ..<\/p>\n\n\n\n<p>4. Delete the associated .cs code-behind file<\/p>\n\n\n\n<p>That&#8217;s it! Now you have a single file solution that dynamically compiles.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To convert a code-behind ASPX to an inline ASPX page: 1. Modify Page directive to read &lt;%@ Page Language=&#8221;cs&#8221; Strict=&#8221;True&#8221; %&gt; 2. Paste code into into script tag in the header &lt;HEAD&gt;&lt;SCRIPT language=&#8221;cs&#8221; runat=&#8221;server&#8221;&gt; .. your code goes here .. &lt;\/SCRIPT&gt;&lt;\/HEAD&gt; only paste the code INSIDE the page class, under the &#8221; Web Form Designer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4],"tags":[],"class_list":["post-671","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=671"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/671\/revisions"}],"predecessor-version":[{"id":3701,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/671\/revisions\/3701"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}