13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Chapter 1: Introduction to <strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong> 11runat="server"> Press the button to receive all of your hopes and dreams:Along with the <strong>ASP</strong>.<strong>NET</strong> code, the C# code is generated in a separate CS file knownas code behind. As you will see, the C# code is primarily used to trigger events thatlaunch an <strong>ASP</strong>.<strong>NET</strong> script. The following C# code largely has been generated by VisualStudio 2008, and the only line that the developer needs to add is a statement telling theapplication to take the input from the asp:TextBox and put it into the asp:Label.The code also deletes the default launch event of Page_Load that launches any actionsas soon as the page is loaded. This script waits until the user clicks the button to launchthe action that adds content to the asp:Label form.Dreamer.aspx.csusing System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Xml.Linq;public partial class _Dreamer : System.Web.UI.Page{protected void DoDream(object sender, EventArgs e){Dreams.Text = DreamBox.Text + "'s dreams are big ones!";}}

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

Saved successfully!

Ooh no, something went wrong!