08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50<br />

CHAPTER 3 ■ WEB FORMS WITH <strong>ASP</strong>.<strong>NET</strong><br />

<br />

<br />

First Number &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<br />

<br />

Second Number&nbsp;&nbsp;&nbsp;<br />

<br />

<br />

Add<br />

Subtract<br />

<br />

<br />

<br />

<br />

The Result is:<br />

<br />

<br />

<br />

<br />

You will now need to modify the Page_Load method once again to h<strong>and</strong>le the text<br />

boxes instead of the more general input fields. Because you’ll be using <strong>ASP</strong>.<strong>NET</strong> controls<br />

that the server “sees” <strong>and</strong> can underst<strong>and</strong>, you don’t need to pull the values to add <strong>and</strong><br />

subtract from the Request.Form array as you did previously. Instead, you simply access<br />

each TextBox control’s Text property. You can see this in Listing 3-8.<br />

Listing 3-8. Page_Load Modified for <strong>ASP</strong>.<strong>NET</strong> Text Boxes<br />

using System;<br />

using System.Data;<br />

using System.Configuration;<br />

using System.<strong>Web</strong>;<br />

using System.<strong>Web</strong>.Security;<br />

using System.<strong>Web</strong>.UI;<br />

using System.<strong>Web</strong>.UI.<strong>Web</strong>Controls;<br />

using System.<strong>Web</strong>.UI.<strong>Web</strong>Controls.<strong>Web</strong>Parts;<br />

using System.<strong>Web</strong>.UI.HtmlControls;<br />

public partial class _Default : System.<strong>Web</strong>.UI.Page<br />

{<br />

protected void Page_Load(object sender, EventArgs e)<br />

{

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!