Anda di halaman 1dari 7

BT0042

SEM 3
SET 1
Introduction to .NET technologies

1.
a) Web Applications
A collection of elements that make up website or distinct portion of a website organized under a virtual root.
Web applications are built from web projects. A web project can reference a web applications. For example
we can have a website with two web applications. One that defines an online catalog and one that defines
pages for administrating the database for the catalog. How and when web files are processed depends on a
variety of factors including the stage of the development we are in, the project mode we are working in and
the needs of our web application.. each web appli9cation requires a combination of hardware and software
pieces that are needed for developing a web application that incorporates a database.

b) Web Server Connections


The detailed interaction of the components depends on the mode of our projects. Typically the system
components interact using HTTP, except for the database components which likely to use local area network
(LAN) connection wide area network (WAN). Communicating via HTTP allows us to develop a web
application in a distributed environment where the master web server and local development machine might
only be connected via internet. An HTTP connection also allows us to connect to the master web server
through firewalls and proxy servers that protect us from unauthorized accesses to our local development
site. A production server that is separate from our master web server is recommended because it provides an
added layer of protection. If u have multiple developers updating the master server with their local files, it is
possible that the changes made by one developer can conflict the changes made by another, and “break”
parts of web application shown to the public when the “final” working version of the web application is
available.

2. Syntax and semantics of ASP.NET program


The following program demonstrates how to place a label in the Web Form using ASPX
<%@ Page Language=”C#”% Codebehind=”Label.aspx.cs”%>
<html>
<head>
<title>Simple Web Form</title>
</head>
,body>
<center>
Form id=”Form” method=”post” runat =server>
<asp:Label id=”Label1” runat=server>
<asp:Label id=”Label1” runat=server>
A simple web form
</asp:Label>
</form>
</center>
</body>
</hml>

3. The validation controls always perform validation checking in the server code. If the user is working with
a browser that supports DHTML, the validation controls can also perform validation using client script.
With the client side validation, any errors are detected on the client when the form is submitted to the server.
If any of the validators are found in error, the submission of the form to the server is cancelled and the
validator`s text property is displayed. This permits the user to correct the input before submitting the form to
the server. Field values are revalidated as soon as the field containing errors loose focus, thus providing the
user with a rich, interactive validation experience.
Client side validation is enabled by default. If the client is capable, up level validation will be performed
automatically. To disable client-side validation, set the page’s ClientTarget property to ``downlevel``
(``Uplevel`` forces client side validation)

Program
<html>
<head>
<script language=``VB`` runat=``server`>
Sub page load
If Not Is PostBack
`Validate initially to force 8s to appear before the first round-trip
Validate()
End if
End sub
Sub validationBtn_click(sender as object, e as EventArgs)
If (page.IsValid) Then
lbloutput.Text = ``page is valid! ``
Else
lblOutput.text=`` Some of the required fields are empty ``
end if
end sub
</script>
</head>
<body>
<H3><font face=”Verdana”> Client-side Required Field Validator
Sample</font></h3>
<p>
<form runat= “ server”>
<table bgcolor=”#eeeeee” cellpadding=10>
<tr valign= “top”>
<tr colspan=3>
<asp:label id= “lblOutput” Name= “lblOutput” Text=”fill in the required fields below” forecolor=”red”
font-name=”Verdana” Font-size= “10” runat=server/><br>
</td>
</tr>
<tr>
<td colspan=3>
<font face=Verdana size=2><b> credit card information</b></font>
</td>
</tr>
<tr>
<td align=right>
<font face=Verdana size=2>Card Type:</font>
</td>
<td>
<ASP.RadioBUttonList id= RadioButtonList1 RepeatLayout=”flow”
onclick=”clientOnChange(); “runat=server>
<asp:listitem>master card</asp:listitem>
Asp:listitem>visa</asp:listitem>
</ASP:RadioButtonList>
</td>
<td align=middle rowspan=1>
<asp:RequiredFieldValidator id=”RequiredFieldValidator1”
ControltoValidate=”RadioButtonList1”
Display=”Static”
InitialValue=””
Width=”100%”>
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align=right>
<font face= verdana size=2> card number:</font>
</td>
<td.
<ASP:TextBox id = TextBox1 Runat=server/>
</td>
<td.
<asp:RequiredFieldValidator id= “RequiredFieldValidator2”
ControlToValidate= “TextBox1”
Display=”Static”
Width=”100” runat=server>
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align right>
<font face= Verdana size=2>Expiration Date:</font>
</tr>
<td>
<ASP: DropDownList id=DropDownList1 runat=server
<asp: listItem></asp: ListItem>
<asp: listItem>06/00</asp: ListItem>
<asp: listItem>07/00</asp: ListItem>
<asp: listItem>08/00</asp: ListItem>
<asp: listItem>09/00</asp: ListItem>
<asp: listItem>10/00</asp: ListItem>
<asp: listItem>11/00</asp: ListItem>
<asp: listItem>01/01</asp: ListItem>
<asp: listItem>02/01</asp: ListItem>
<asp: listItem>03/01</asp: ListItem>
<asp: listItem>04/01</asp: ListItem>
<asp: listItem>05/01</asp: ListItem>
<asp: listItem>06/01</asp: ListItem>
<asp: listItem>07/01</asp: ListItem>
<asp: listItem>08/01</asp: ListItem>
<asp: listItem>09/01</asp: ListItem>
<asp: listItem>10/01</asp: ListItem>
<asp: listItem>11/01</asp: ListItem>
<asp: listItem>12/01</asp: ListItem>
</ASP:DropDownList>
</td>
<td>
<asp:requiredFieldValidator id=”RequiredFieldValidator3”
ControlToValiadate=”DropDownList`”
Display=”Static”
InitialValue=””Width=”100%” runat=server>
</asp:RequiredFieldValidator>
</td>
<td>
</tr>
<tr>
<td></td>
<td>
<ASP:Button id=Button1 text=”Validate” OnClick=”ValidateBtn_Click”
Runat=server/>
</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>

4. If a validation control is an error, an error message may be displayed in the page by that validation control
or in a ValidationSummary control elsewhere on the page. The ValidationSummary control is displayed
when the IsValid property of the page is false. It polls each of the validation controls on the page and
aggregates the text messages exposed by each. The following example illustrates displaying errors with a
ValidationSummary control.

Program
<html>
<head>
<script language=”VB” runat=”server”>
Sub ListFormay_SelectedIndexChanged (sender As Object, e as EventArgs)
` Change display mode of validator summary when a new option is selected from the “listFormat”
dropdownlist
valSum.DisplayMode = ListFormat.SelectIndex
End Sub
</script>
</head>
<body.
<h3><font face= “verdana”> ValidationSummary Sample</font><h3>
<p>
<form runat=”server”>
<table cellpadding= 10>
<tr>
<td>
<table bgcolor=”eeeeee” cellpadding=10>
<tr>
<td colspan = 3>
<font face= verdana size=2><b>Credit Card Information</b></font>
</td>
</tr>
<tr>
<td align= right>
<font face=Verdana size= 2> Card Type:</font>
</td>
<td>
<ASP:RadioButtonList id= RadioButtonList1 RepeatLayout = “Flow” runat= server>
<asp:ListItem>MasterCard </asp:ListItem>
<asp:ListItem>Visa</asp:ListItem>
</ASP:RAdioButtonList>
</td>
<td align= middle rowspan=1>
<asp:RequiredFieldValidator id= “RequiredFieldValidator2”
ControlToValidate= “RadioButtonList1”
ErrorMessage= “Card Type. ”
Display=”Static”
InitialValue=Width=”100%” runat=server>
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align=right>
<font face= verdana size=2>Card Nunber:</font>
</td>
<td>
<ASP:TextBox id=TextBox1 runat=server />
</td>
<td>
Asp:requiredFieldValidator id=”RequiredFieldValidator@”
ControlToValidator=”Textbox1”
ErrorMessage=”TextBox1”
Display=”Static”
Width=”100%” runat=server>
</asp:requiredFieldValidator>
</td>
</tr>
<tr>
<td align=right>
<font face=Verdana size=2>Expiration date:</font>
</td>
<td>
<ASP:DropDownList id=DropDownList1 runat=server>
<asp:ListItem></asp:ListItem>
<asp: listItem>06/00</asp: ListItem>
<asp: listItem>07/00</asp: ListItem>
<asp: listItem>08/00</asp: ListItem>
<asp: listItem>09/00</asp: ListItem>
<asp: listItem>10/00</asp: ListItem>
<asp: listItem>11/00</asp: ListItem>
<asp: listItem>01/01</asp: ListItem>
<asp: listItem>02/01</asp: ListItem>
<asp: listItem>03/01</asp: ListItem>
<asp: listItem>04/01</asp: ListItem>
<asp: listItem>05/01</asp: ListItem>
<asp: listItem>06/01</asp: ListItem>
<asp: listItem>07/01</asp: ListItem>
<asp: listItem>08/01</asp: ListItem>
<asp: listItem>09/01</asp: ListItem>
<asp: listItem>10/01</asp: ListItem>
<asp: listItem>11/01</asp: ListItem>
<asp: listItem>12/01</asp: ListItem>
</ASP:DropDownList>
</td>
</tr>
<asp:RequitredFieldValidator id=”RequiredFieldValidator3”
ControlToValidate=”DropDownList1”
ErrorMessage=”Expiration Date. “
Display=”Static”
InitialValue=””
Width=”100%”
runat=server>
</asp: RequiredFieldValidator>
</td>
<td>
</tr>
<tr>
<td></td>
<td>
ASP: button id= Button1 text=”Validate” runat=server/>
</td>
<td></td>
</tr>
</table>
</td>
<td valign=top>
<table cellpadding=20><tr><td>
<asp:ValidationSummary ID=”valSum” runat=”server”
HeaderText “ You must enter the value in the following fields :”
Font-Name= “Verdana “
Font-Size=”12”
/>
</td><?tr></table>
</td>
</tr>
</table>
<font face=”verdana” size=”-1”> select the type of validation summary display you wish: </font>
<asp:DropDownList id=”ListFormat” AutoPostBack=True
OnSelectedIndexChanged=”ListFormat” AutoPostBack=true
OnSelectedIndex Changed=”ListFormat_SelectedIndexChanged” runat= server >
<asp:listItem>List</asp:ListItem>
<asp:ListItem selected>bulleted List</asp:ListItem>
Asp:ListItem>Single Paragraph</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</html>

Anda mungkin juga menyukai