spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column114


JScript .NET, Part VIII: Consuming IsPrime from ASP.NET

Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Writing ASP.NET Controls

An ASP.NET page is similar to an HTML page. It includes tags and event handlers. The tags' syntax is similar to that of HTML tags. You write event handlers in JScript .NET. To call the IsPrime Web service, we use only two ASP.NET tags: ASP:BUTTON and ASP:TEXTBOX. All of ASP.NET's tag parameters are specified within the opening brackets, so you can end them with a "/" inside the opening brackets, or with a "/" concatenated with the tag name, in separate closing brackets. The following two formats are valid:

<ASP:TEXTBOX ...... />
<ASP:TEXTBOX ........></ASP:TEXTBOX>

ASP.NET pages are saved with the extension .aspx. Our ASP.NET page that consumes the IsPrime Web service is checkIsPrime.aspx. Here is the BODY section of the ASP.NET page:


<BODY STYLE="font-size:12;
  font-family:arial,verdana,sans-serif;">
  <FORM RUNAT="server">
    <TABLE BORDER="0">
      <TR>
       <TD ALIGN="middle"><ASP:TEXTBOX ID="first"
        RUNAT="server" SIZE="4" STYLE="text-align:'right'"/>
        </TD>
       <TD ALIGN="middle"><ASP:LABEL ID="resultControl"
        RUNAT="server"/></TD>
	  </TR>
	  <TR>
	    <TD><ASP:BUTTON TEXT="Is Prime?" ID="isprime"
		  OnClick="Submit_Click" RUNAT="server"/></TD>
	  </TR>
    </TABLE>
  </FORM>
</BODY>

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"
  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 ASP:TEXTBOX tag's ID is first. The ASP:LABEL tag is as follows:


<TD ALIGN="middle">
<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.


Next: How to write JScript .NET for ASP.NET

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: July 15, 2002
Revised: July 15, 2002

URL: http://www.webreference.com/js/column114/4.html