You are on page 1of 7

ASSIGNMENT-2

INT 452

SUBMITTED TO: RAHUL SALHAN Roll no. RA17T5A21 Section: RA17T5 Reg. no-7050070107 B.Tech (H) CSE

SUBMITTED BY: AMRIT PAL SINGH

Part (A) 1. Create a WebPage to list the courses a student will be required to pursue using the various Web controls available in ASP.NET. Use appropriate assumptions and also discuss the concept of making HTML controls Server Side controls. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs" Inherits="home" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <table style="z-index: 100; left: 0px; color: #000000; position: absolute; top: 0px; background-color: #ccccff"> <tr> <td align="center" colspan="4" style="font-weight: bold; font-size: 16pt"> COURSES OFFERED</td> </tr> <tr> <td style="width: 100px"> S.No</td> <td style="width: 227px"> Course </td> <td style="width: 100px"> Course code</td> <td style="width: 100px"> Tick to choose</td> </tr> <tr> <td style="width: 100px"> 1</td> <td style="width: 227px"> ANALYSIS AND DESIGN OF ALGORITHMS</td> <td style="width: 100px"> CSE 458</td> <td style="width: 100px"> <input id="Checkbox1" type="checkbox" /></td>//HTML CONTROL </tr> <tr>

<td style="width: 100px"> 2</td> <td style="width: 227px"> MODERN PROGRAMMING TOOLS AND TECHNIQUES-II</td> <td style="width: 100px"> CSE 456</td> <td style="width: 100px"> <input id="Checkbox2" type="checkbox" /></td>//HTML CONTROL </tr> <tr> <td style="width: 100px"> 3</td> <td style="width: 227px"> WEB MANAGEMENT AND ADMINISTRATION</td> <td style="width: 100px"> INT 552</td> <td style="width: 100px"> <input id="Checkbox3" type="checkbox" /></td> </tr> <tr> <td style="width: 100px"> 4</td> <td style="width: 227px"> MODERN WEB PROGRAMMING TOOLS AND TECHNIQUES-I</td> <td style="width: 100px"> INT 452</td> <td style="width: 100px"> <input id="Checkbox4" type="checkbox" /></td> </tr> <tr> <td style="width: 100px"> 5</td> <td style="width: 227px"> WEB DEVELOPMENT</td> <td style="width: 100px"> CAP 426</td> <td style="width: 100px"> <input id="Checkbox5" type="checkbox" /></td> //HTML CONTROL </tr> <tr> <td align="center" colspan="4"> <asp:Button ID="Button1" runat="server" Text="SUBMIT" /> <asp:Button ID="Button2" runat="server" Text="RESET" /></td> </tr> </table> </div> </form> </body> </html>

Q2 Explain the various objects in ASP.NET? There are five types of built in objects 1) Request Object (It is used to access the information sent in a request from a browser to the server). 2) Response Object (It is used to send information to the browser). 3) Session Object (It is used to store & retrieve information about particular user sessions). 4) Application object (It is used to store & retrieve information that can be shared among all the users of an application). 5) Server Object (It is used to access various utility functions on the server). Q3 Name a difference between an <asp: DropDownList> and an <asp: ListBox>. The basic difference between DropDownList and ListBox in ASP.NET are following 1. Only one items of DropDownList is visible when it renders on the page. More than one item of the ListBox is visible when it renders on the page. 2. Only one item can be selected in DropDownList. More than one item can be selected in Listbox provided SelectionMode is Multiple as in the below code snippets. Both controls are rendered as "<select>" html tag in the HTML.

DROPDOWNLIST <asp:DropDownList ID="drop1" runat="server"> <asp:ListItem Text="One" Value="1" /> <asp:ListItem Text="Two" Value="2" /> </asp:DropDownList> LIST BOX <asp:ListBox ID="list1" runat="server" SelectionMode="Multiple">

<asp:ListItem Text="One" Value="1" /> <asp:ListItem Text="Two" Value="2" /> </asp:ListBox>

Q4 What property do you need to cause a postback to the server when you change the checked state of a CheckBox in the browser? AutoPostBack property is answer The CheckBoxList control raises a SelectedIndexChanged event when users select any check box in the list. By default, the event does not cause the page to be posted to the server. However, you can force the control to perform an immediate postback by setting the AutoPostBack property to true.

Part (B) Q5 Make a WebPage which automatically sends an e-mail to the recent visitor accessing the WebPage, on occurrence of an event which causes the closing of webpage. Ask for the details and make appropriate assumptions accordingly. using System.Net.Mail; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { MailMessage mail = new MailMessage(); mail.To.Add("haridwar.varun@gmail.com"); mail.From = new MailAddress("rahulsalhan@gmail.com"); mail.Subject = "Email using Gmail";

string Body = "Hi, this mail is to test sending mail" + "using Gmail in ASP.NET"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new System.Net.NetworkCredential("varunlpu@gmail.com", "passsword");

smtp.EnableSsl = true; smtp.Send(mail); } }

Q6 Make a WebPage for processing the details of a student in a typical university. Use the various validation controls to ensure that Web Controls placed on WebPage are accepting the valid data.

Six validation controls are included in the ASP.NET Framework 1) RequiredFieldValidatorEnables you to require a user to enter a value in a form field. 2) RangeValidatorEnables you to check whether a value falls between a certain minimum and maximum value. 3) CompareValidatorEnables you to compare a value against another value or perform a data type check. 4) RegularExpressionValidatorEnables you to compare a value against a regular expression. 5) CustomValidatorEnables you to perform custom validation. 6) ValidationSummaryEnables you to display a summary of all validation errors in a page.

Q7 Make a WebPage (to show the behaviour of Response Object) in which you have a Button Control and four RadioButton Controls with a common GroupName property. The user will be sent to a new page if he makes a selection from one of the Radio Buttons and hits the submit button. using using using using using using using using using System; System.Data; System.Configuration; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click (object sender, EventArgs e) { if (RadioButtonList1.SelectedIndex == 0) Response.Redirect("home.aspx"); else if (RadioButtonList1.SelectedIndex == 1) Response.Redirect("registration,aspx"); else if (RadioButtonList1.SelectedIndex == 2) Response.Redirect("videogallery.aspx"); else if (RadioButtonList1.SelectedIndex == 3) Response.Redirect("feedback.aspx"); } }

You might also like