Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.

Similar presentations


Presentation on theme: "CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages."— Presentation transcript:

1 CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages

2 2 Active Server Pages Active Server Page approach: Create “form” which is translated to html

3 3 Active Server Pages Server-side code manipulates “form elements” – Subroutine called when page submitted – Data read from elements (actually request string) – Used to set value of other elements

4 4 Active Server Pages Resulting form translated to response page

5 ASP/IIS Architecture IIS routes request to ASP.NET if.aspx file requested ASP.NET loads requested.aspx file, runs code, and converts resulting form to html file

6 Creating a New Web Site Choose File  New Web Site Choose “ASP.NET Empty Web Site” – Can select either Visual Basic or Visual C# – Can set name/ location of site at bottom

7 Adding a Web Form Solution Explorer contains files related to application – Initially Web.config (like web.xml in JSF) Right-click site name in Solution Explorer  Add  New Item

8 Ways to View Page Source: Html source code (can insert html tages) Design: WYSIWYG mode showing corresponding page Split: Both simultaneously

9 Viewing the Web Page Simplest method: Cntrl-F5 Runs page in default browser

10 Toolbox Toolbox on LHS lets you drag components onto page – Similar to VB, VC# – Components not created programmatically

11 Example: Adding a Button Click on the Button option and drag it onto the screen Drag to desired location – Design or Split mode – Within defined area of page

12 Properties Window Visual components commonly edited with Properties box on RHS – Example: Text property controls text displayed on button

13 Setting Component ID Visual components referred to using ID property – Most important property to set (like name in JSP) – Allows code to get/set property values

14 ASP and Dynamic Pages Code used to manipulate ASP site – Code activated by event (such as submit button being pressed) – Code can read properties of visual controls – Code can modify properties of other visual controls to change page

15 “Hello World” Example Textbox for name – ID = nameBox Label for greeting – ID = greetLabel, Text = “” Button to activate code – ID = helloButton (not strictly necessary, but good practice)

16 Accessing Code Window Double-click on window shows code associated with events (“code behind”) –.cs file associated with all events – Page_Load = code executed when page loaded – helloButton_Click executed when button pressed

17 Adding Code Code added to helloButton_Click executed when button pressed Get the Text property of the nameBox Append that name to the rest of the string using “+” Write that string into the Text property of the greetLabel

18 Viewing the Result Run with Cntrl-F5, enter a name and press the button The code is executed: – String read from Text property of nameBox – String written to Text property of greetLabel

19 Default Post Back Mode By default, same page requested from server All component values automatically echoed in page sent back as response – Similar to JSF

20 How Does This Work? At client side, these components displayed as corresponding html Event causes page to be submitted to server – Form data included in request

21 How Does This Work? By default, same page requested (“postback”) Implemented as Visual Basic/C# form at server side Form data from request written into the properties of the form elements – Parameter value for text element  Text property of TextBox


Download ppt "CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages."

Similar presentations


Ads by Google