Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I developed a solution that solves my problem in VS 2008:</p> <ol> <li><strong>Create Main Site Solution:</strong> Create a MVC 1 Website solution in VS 2008 </li> <li><strong>Create Model Class Library:</strong> Add a Class Library for the Model Code</li> <li><strong>Create View Code:</strong> Add an "Empty Website" to hold the .ascx pages, and add a reference the model library</li> <li><strong>Create Deployment Site:</strong> Add a deployment project that compiles the "Empty Website" goto the "properties page" and <em>Check</em>: "Merge All outputs into a single assembly" and "Treat as library component" and be sure to <em>UnCheck</em>: "Allow this precompiled site to be updatable"</li> <li><strong>Reference Deployment Output:</strong> In the main project add a reference to the output of the Deployment site. </li> <li><p><strong>ASP. - Compiled Controls:</strong> Controls show up under the ASP. namespace and are named in two ways A. if the .ascx / aspx page did not declare a "ClassName" then they are named using their folder and file name with underscores ex. &lt;%@ Control Language="C#" ClassName="Admin_Index" %> B. if they did declare a class name then that is their name</p></li> <li><p>List item</p></li> </ol> <p><strong>Usage:</strong> Example code is below</p> <p>Here is an example usage</p> <pre><code>public ActionResult Index() { var ctl = new ASP.Directory_FirmProfile(); //create an instance ctl.Setup(new MyDataModel); //assign data //string test = CompiledControl.Render(ctl); //output to string return new HtmlCtl.StrongView(ctl); //output to response } public class CompiledControl { public static string Render(Control c) { Page pageHolder = new Page(); pageHolder.Controls.Add(c); StringWriter output = new StringWriter(); HttpContext.Current.Server.Execute(pageHolder, output, false); return output.ToString(); } public static void Render(Control c, StringWriter output) { Page pageHolder = new Page(); pageHolder.Controls.Add(c); HttpContext.Current.Server.Execute(pageHolder, output, false); } public static void Render(Control c, HttpResponseBase r) { Page pageHolder = new Page(); pageHolder.Controls.Add(c); HttpContext.Current.Server.Execute(pageHolder, r.Output, false); } } public class StrongView : ActionResult { private Control ctl; public StrongView(Control ctl) { this.ctl = ctl; } public string VirtualPath{get;set;} public override void ExecuteResult(ControllerContext context) { if (context == null) throw new ArgumentNullException("context"); HtmlCtl.CompiledControl.Render(ctl, context.HttpContext.Response); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload