Multimedia and Advance Web Technologies
By:
Dr. Mohammad Shoab
Week 10 & 11
Introduction to ASP.NET
2
Multimedia and Advance Web Technologies
Department of Computer Science
Introduction to ASP.NET
3
Multimedia and Advance Web Technologies
Department of Computer Science
4
ASP.NET Architecture
Common Language Specification
Common Language Runtime
VB
C++
C#
ASP.NET: Web Services
and Web Forms
JScript
…
Windows�Forms
Base Classes
ADO.NET: Data and XML
Visual Studio.NET
Multimedia and Advance Web Technologies
Department of Computer Science
Working of an ASP.NET Application
To execute an ASP.NET file, the following steps are followed:
CLIENT
WEB SERVER
ASP.NET
Script
Engine
5
Multimedia and Advance Web Technologies
Department of Computer Science
Working of an ASP.NET Application
4. The ASP.NET script engine reads the file from top to bottom and executes it.
5. The processed ASP.NET file is generated as an HTML document and the ASP.NET script engine sends the HTML page to the Web server.
6. The Web server then sends the HTML code to the client which interprets the output and displays it.
CLIENT
WEB SERVER
ASP.NET
Script
Engine
6
Multimedia and Advance Web Technologies
Department of Computer Science
Advantages of ASP.NET
7
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls, Validation Controls, User Controls, Master Pages
8
Multimedia and Advance Web Technologies
Department of Computer Science
Web Controls
9
Multimedia and Advance Web Technologies
Department of Computer Science
10
Multimedia and Advance Web Technologies
Department of Computer Science
11
Multimedia and Advance Web Technologies
Department of Computer Science
HTML server controls
12
Multimedia and Advance Web Technologies
Department of Computer Science
HTML server controls
13
Multimedia and Advance Web Technologies
Department of Computer Science
Web server controls
14
Multimedia and Advance Web Technologies
Department of Computer Science
Web server controls
15
Multimedia and Advance Web Technologies
Department of Computer Science
Label
The Label Web Server control The Label Web Server control is used to label other parts of the application. They are used to display text which the user can't change. To display text on a label we use the text property.
16
Multimedia and Advance Web Technologies
Department of Computer Science
Literal
17
Multimedia and Advance Web Technologies
Department of Computer Science
Buttons
A Button Web Server control A Button Web Server control is a control which we click and release to perform some action.
The default event of the Button is the Click event which looks like this in code:
Private Sub Button1_Click(ByVal sender As System Private Sub Button1_Click(ByVal sender As System.Object,_�ByVal e As System.EventArgs) Handles Button1.Click��'Implementation Omitted��End Sub
18
Multimedia and Advance Web Technologies
Department of Computer Science
Link Button
19
Multimedia and Advance Web Technologies
Department of Computer Science
ImageButton Control
20
Multimedia and Advance Web Technologies
Department of Computer Science
DropDownList
The DropDownList Web server control The DropDownList Web server control is same as the ListBox control but it supports only single selection and displays items in a drop-down manner
21
Multimedia and Advance Web Technologies
Department of Computer Science
ListBox
22
Multimedia and Advance Web Technologies
Department of Computer Science
CheckBox
23
Multimedia and Advance Web Technologies
Department of Computer Science
CheckBoxList
24
Multimedia and Advance Web Technologies
Department of Computer Science
RadioButtonList
25
Multimedia and Advance Web Technologies
Department of Computer Science
RadioButton
The RadioButton Web server control The RadioButton Web server control is similar to CheckBox but RadioButtons are displayed as rounded instead of box.
26
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
27
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
28
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
29
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
30
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
<asp:TextBox id=TextBox1 runat=server />
<asp:RequiredFieldValidator id="Req1"
ControlToValidate="TextBox1"
Text="Required Field" runat=server />
31
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
void Submit_click(object s, EventArgs e) {
if (Page.IsValid) {
Message.Text = "Page is valid!";
}
}
32
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
<% @ Page Language="c#"
ClientTarget="DownLevel" %>
33
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
34
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
35
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
Examining the Client-Side XHTML for a Web Form with Validation
36
Multimedia and Advance Web Technologies
Department of Computer Science
Server Controls �Validation Controls
Performance Tip
Setting EnableViewState to False reduces the amount of data passed to the web server with each request.
37
Multimedia and Advance Web Technologies
Department of Computer Science
Validation Controls Example
38
Multimedia and Advance Web Technologies
Department of Computer Science
Validation Controls Example
39
Multimedia and Advance Web Technologies
Department of Computer Science
Validation Controls Example
40
Multimedia and Advance Web Technologies
Department of Computer Science
Validation Controls Example
41
Multimedia and Advance Web Technologies
Department of Computer Science
Project Structure
42
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
Creating a Master Page
43
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
44
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
45
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
46
Multimedia and Advance Web Technologies
Department of Computer Science
Bug2Bug.master page that defines a logo image header for all pages
47
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
Creating a Content Page
48
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
49
Multimedia and Advance Web Technologies
Department of Computer Science
Master Pages
Adding a CreateUserWizard Control to a Content Page
50
Multimedia and Advance Web Technologies
Department of Computer Science
CreateUserWizard requires 'jquery'
<appSettings>
<add
key="ValidationSettings:UnobtrusiveValidationMode"
value="none"/>
</appSettings>
51
Multimedia and Advance Web Technologies
Department of Computer Science
Creating Controls
52
Multimedia and Advance Web Technologies
Department of Computer Science
Creating Controls�User Controls
53
Multimedia and Advance Web Technologies
Department of Computer Science
Why Use User Controls?
Page2.aspx
Control1.ascx
Page1.aspx
Page3.aspx
Application A
Application B
Adding a User Control
<%@ Register TagPrefix="demo"
TagName="validNum" Src="numberbox.ascx" %>
<demo:validNum id="num1" runat="server"/>
num1.pNum = 5; //uses Set
x = num1.pNum; //uses Get
55
Multimedia and Advance Web Technologies
Department of Computer Science
Example User Control
56
Multimedia and Advance Web Technologies
Department of Computer Science
Creating Controls�Programmatic Use of User Controls
Control numbox1 = Page.LoadControl("numberbox.ascx");
myPanel.Controls.Add(foo);
57
Multimedia and Advance Web Technologies
Department of Computer Science
Creating Controls�Custom Controls
58
Multimedia and Advance Web Technologies
Department of Computer Science
Creating Controls�Custom Controls vs. User Controls
User Controls | Custom Controls |
Good for application-specific UI | Good for reuse, �encapsulate common UI |
Easy to build | Can be more complex to build |
Less flexibility, performance, designer support | Total flexibility, better performance, and designer support |
No template support | Can support templates |
59
Multimedia and Advance Web Technologies
Department of Computer Science
The End
60
Multimedia and Advance Web Technologies
Department of Computer Science
Exercise
Q1. Explain ASP.NET.
Q2. Draw the diagram of ASP.NET architecture.
Q3. What are the advantages of ASP.NET
Q4. What is web control? Write the types of web controls.
Q5. Explain HTML server controls.
Q6. Explain web server controls.
Q7. Explain validation controls.
Q8. What is master page?
Q9. What are the differences between custom controls and user controls.
61
Multimedia and Advance Web Technologies
Department of Computer Science
Q10. What is ASP?
Q11. A web browser sends a request for an ASP.NET file to the web server by using a
62
Multimedia and Advance Web Technologies
Department of Computer Science
Q12. A control is an object that can be drawn on to the
Q13. When the XHTML for our page is created, the validator is converted into
63
Multimedia and Advance Web Technologies
Department of Computer Science
Q14. Validation controls contain text which is displayed only if
Q15. The master page defines the elements we want to appear on
64
Multimedia and Advance Web Technologies
Department of Computer Science