|
August 10, 2002 Hello World's Code Behind Version Tips: August 2002
Yehuda Shiran, Ph.D.
|
|
Let's demonstrate the Code Behind concept with JScript .NET code that prints the message "Hello World, Code Behind":
First, notice that we don't import any external namespaces. The reason for this is that we don't reference external classes in this particular example. In general, you would put all your import statements before the package definition. As a reminder, all namespaces are available for the JScript compiler, even without importing them. The only reason to import a namespace is to avoid writing the namespace name in front of the class name, like ASPPlus.CodeBehind.
The
The function Page_Load() is an intrinsic function. It is invoked automatically when the ASP.NET page loads. You don't need to set the onload event handler definition, as you would do in client-side JavaScript. The Page_Load() function includes one statement in which we set the Text property of the message ASP:Label control:
Notice that the function returns void, because we don't return any value from the function, just setting message.Text. Also, the JScript .NET variable and property names are case sensitive. If you would try setting the value of message.text (text begins with a lower case t), you would get a compilation error.To learn more about JScript .NET and ASP.NET, go to Column 115, JScript .NET, Part IX: Code Behind.
People who read this tip also read these tips: Look for similar tips by subject: |