spacer
Yehuda Shiran July 28, 2002
Writing Web Forms
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

An ASP.NET form that runs on a Web server is called an ASP.NET Web form, as opposed to the ASP.NET Windows form, used in Windows-based applications. Here is a form that calls the add Web service:

  <FORM METHOD="post" RUNAT="server">
  <TABLE BORDER="0">
  <TR><TD>Enter First Number:</TD><TD><ASP:TEXTBOX RUNAT="server" SIZE="4" 
    ID="first" STYLE="text-align:'right'"/></TD></TR>
  <TR><TD>Enter Second Number:</TD><TD><ASP:TEXTBOX RUNAT="server" SIZE="4"  
    ID="second" STYLE="text-align:'right'"/></TD></TR>
  <TR><TD align="right"><ASP:BUTTON TEXT="Add" ID="doAdd" OnClick="Submit_Click" 
    RUNAT="server"/></TD><TD><HR></TD></TR>
  <TR><TD></TD><TD><ASP:TEXTBOX ID="resultControl" RUNAT="server" 
    STYLE="text-align:'right'" SIZE="4"/></TD></TR>
  </TABLE>
  </FORM>
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, simpleCalcConsumer.aspx. The Web form above includes three ASP:TEXTBOX tags. Here is the first one:

  <ASP:TEXTBOX RUNAT="server" SIZE="4" ID="first" 
    STYLE="text-align:'right'"/>
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 first ASP:TEXTBOX tag's ID is first, the second is second, and the third is resultControl. The ASP:BUTTON tag is as follows:

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

To learn more about JScript .NET and ASP.NET, go to Column 113, JScript .NET, Part VII: Consuming add from ASP.NET.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint