NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

The Pre-Compiled Model

The precompiled control model refers to modules written in a NGWS runtime, CLS-compliant language (C#, Visual Basic 7.0, Managed Extensions for C++), compiled with a command-line compiler to create a .dll, and deployed on the server.

The simple server control class and .aspx file below show how you could take advantage of code-behind page development to cleanly separate logic and presentation code. The example supports a code-behind development mode in which page logic is contained within an external NGWS frameworks class that is compiled prior to deployment and linked to the .aspx file at run time.

Creating the Code Module

The code-behind module can be developed using any language supported by the NGWS runtime. Languages currently supported include C#, Visual Basic 7.0, and Managed Extensions for C++.

/* New class (MyPage) written in C#
*/
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;

public class MyPage : Page {

   protected HtmlContainerControl  Message  = null;
   protected HtmlButton            MyBtn    = null;

   protected override void Init() {
      if (!IsPostBack) {
         Message.InnerHtml = "This is the first time the page has been hit by you!";
      }
   }

   protected void MyBtn_Click(Object source, EventArgs e) {
      Message.InnerHtml = "Thanks! -- You just pushed the button!";
   }
}

Creating the ASP+ file

The ASP+ page that uses a custom server control must include an Inherits directive specifying the code-behind class the ASP+ page inherits.

The following ASP+ page uses the MyPage class developed above.

<%-- ASP+ page uses the MyPage class to respond to a button click. --%>
<%@ Page Description="Uses sample code-behind page" Inherits="MyPage"%>

<html>
   <body>
      <form runat=server>
         <h1><span id="Message" runat=server/></h1>
         <input type=submit value="Push" OnServerClick="MyBtn_Click" runat=server>
      </form>
   </body>
</html>