Download presentation
Presentation is loading. Please wait.
1
ASP.Net Demo ISYS 350
2
ASP.NET is a sever-side technology
1. The client requests a ASP web page. 2. The web server locates the page and execute the page. 3. The output produced by the ASP.Net page is sent to the browser in HTML code.
3
Benefits of Server-Side Technology
Browser compatibility: Every browser reads HTML. Protection of source code. Controls are server-side objects with properties, methods and events.
4
Web Project demo New Project: Add a Web form: A web form contains:
C#/Web/ASP.Net Web Application/Asp.Net Empty Web Application Add a Web form: Project/Add new item/Web form A web form contains: A design file: Ex. webform.aspx Design view Source (HTML) view A code file: Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="testASP.WebForm1" %>
5
Web Form Demo: Create an ASP.Net Web Form to add two numbers
Add controls: Web form flow layout: Controls are positioned from left to right and from top to bottom. Add code: Double-click the form to open the code view. Events: Page_Load event and control’s events
6
ASP.Net Controls: Textbox, listbox, radiobutton list, button, dropdownlist
7
ASP.Net Controls ASP.Net Listbox has three useful properties:
SelectedItem: Displayed item SelectedIndex SelectedValue: Value of the selected item. ASP.Net has a RadioButtonList control that has similar properties as the Listbox.
8
Code Example double pv, rate, year, fv;
pv = double.Parse(TextBox1.Text); rate =double.Parse( ListBox1.SelectedValue); year = double.Parse(RadioButtonList1.SelectedValue); fv = pv * Math.Pow(1 + rate, year); TextBox2.Text = fv.ToString("c"); To set start up page: Point to the web page in the Solution Explorer and right click to choose Set As Start Page.
9
Compute Payment of Loan: Add CSS and Refernce VB to use pmt function
10
<style> div { width: 450px; margin: 0 auto; padding: 15px; background: aqua; border: 2px solid navy; } </style>
11
Code to compute payment
double loan, rate, term, payment; loan = double.Parse(TextBox1.Text); rate = double.Parse(ListBox1.SelectedValue); term = double.Parse(RadioButtonList1.SelectedValue); payment = Financial.Pmt(rate / 12, term * 12, -loan); TextBox2.Text = payment.ToString("c");
12
Use Validator Controls to do Validation
Example: RequiredFieldValidator Add the validator after the Loan textbox Control to Validate: TextBox1 Add this to the web.config file: <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings>
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.