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!

Code Declaration Blocks

Code declaration blocks define member variables and methods to be compiled into the dynamically generated Page class that represents the ASP+ page.

<script runat=”server” [language=”codelanguage] >
   Code goes here….
</script>

In addition, an external file containing script can be specified:

< script runat=”server” [language=”codelanguage] [src=”externalfilename] />

Parameters

codelanguage
Specifies the language used in this code declaration block.
externalfilename
The name of a script file to load. When the src attribute is used, any other code in the declaration block is ignored.

Remarks

Code declaration blocks are defined using <script> tags that contain a runat attribute defined as “server”. The <script> tag may optionally utilize a language attribute to specify the language of its inner code. If none is specified, ASP+ will default to the language configured for the base page (controlled using the @ Page Directive).

The <script> tag may also optionally specify an external script file by defining a src attribute. When the src attribute is defined, all inner content within a <script runat=server> tag is ignored and the abbreviated form of the closing tag (/>) is used rather than </script>.

Example

The following example demonstrates how you could define event-handling logic for the EnterBtn_Click event.

<html>
  <script language="C#" runat="server">
      void EnterBtn_Click(Object Src, EventArgs E) {
          Message.Text = "Hi " + Name.Text + ", welcome to ASP+!";
      }
  </script>

  <body>
   <form runat="server">
    Enter your name: <asp:textbox id="Name" runat=server/> 
                     <asp:button text="Enter" Onclick="EnterBtn_Click" runat="server"/>
        <p>
        <asp:label id="Message" runat=server/>
    </form>
  </body>
</html>

See Also

ASP+ Page Syntax