August 5, 2002 - Writing IsPrime's Consumer in ASP.NET | WebReference

August 5, 2002 - Writing IsPrime's Consumer in ASP.NET

Yehuda Shiran August 5, 2002
Writing IsPrime's Consumer in ASP.NET
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

The following code is the BODY section of the ASP.NET page that consumes the IsPrime Web service:

  <BODY STYLE="font-size:12; font-family:arial,verdana,sans-serif;">
    <FORM RUNAT="server">
      <TABLE BORDER="0">
          <TD ALIGN="middle"><ASP:TEXTBOX ID="first" 
		    RUNAT="server" SIZE="4" STYLE="text-align:'right'"/></TD>
          <TD ALIGN="middle"><ASP:LABEL ID="resultControl" 
          <TD><ASP:BUTTON TEXT="Is Prime?" ID="isprime" 
		    OnClick="Submit_Click" RUNAT="server"/></TD>
All tags include the RUNAT="server" parameter, directing the browser to run it on the Web server. The first tag is FORM. Its only parameter is RUNAT="server". By default, the server always posts the form back to the same originating page, isPrimeConsumer.aspx. Since this form runs on the server, it is called the ASP.NET Web form, as opposed to the ASP.NET Windows form, used in Windows-based applications.

The Web form above includes a single ASP:TEXTBOX tag:

  <ASP:TEXTBOX RUNAT="server" SIZE="4" ID="first" 
The parameters are straightforward. The ID parameter is used to reference the control from other places on the page such as event handlers.

Notice we use the short-hand notation for closing tags. The ASP:TEXTBOX tag's ID is first. The ASP:LABEL tag is as follows:

  <ASP:LABEL ID="resultControl" RUNAT="server"/></TD>
The button is implemented with the ASP:BUTTON tag:

  <ASP:BUTTON TEXT="Is Prime?" ID="isprime" OnClick="Submit_Click" RUNAT="server"/>
The parameters are TEXT and ID. The TEXT parameter specifies the label of the button. We set it to "Is Prime?". Its ID is isprime. In the event of a click, the function Submit_Click() is called.

To learn more about JScript .NET and ASP.NET, go to Column 114, JScript .NET, Part VIII: Consuming IsPrime from ASP.NET.