ASP PAGE STRUCTURE-CODE DECLARATION BLOCKS

Code Declaration Blocks

  • A code declaration block contains all the application logic for  ASP.NET page and all the global variable declarations, subroutines, and functions.
  •  It must appear within a <Script Runat="Server"> tag.
  • We can declare subroutines and functions only within a code declaration block.
  •  We receive an error if we attempt to define a function or subroutine in any other section of an ASP.NET page.
  • The <Script Runat="Server"> tag accepts two optional attributes. 
  • First, We can specify the programming language to use within the <Script> tag by including a language attribute like this:

<Script Language="C#" Runat="Server">

  • If we don't specify a language, the language defaults to the one defined by the <%@ Page Language %> directive .
  •  If no language is specified in a page, the language defaults to Visual Basic.
  • The second optional attribute of the <Script Runat="Server"> tag is SRC. 
  • We can use it to specify an external file that contains the contents of the code block. 

<Script Runat="Server" SRC="ApplicationLogic.aspx"/>


No comments:

Post a Comment