Creating an ASP.NET Web Form with RadioButtons, DropDownList, and Calendar Controls, Lecture notes of Physics

This document demonstrates how to create an asp.net web form using visual studio and c# code. It includes the use of radiobuttons, dropdownlist, and calendar controls. The document also covers how to display messages, vacations, and selected days in the calendar control, as well as the difference between two calendar controls.

Typology: Lecture notes

2018/2019

Uploaded on 09/29/2019

simran710a
simran710a 🇮🇳

1 document

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PRACTICAL NO-3
AIM-create a simple web page with various server controls to demonstrate setting and use of
their properties.
Steps:
Step:-1 Open a Visual studio.
Step:-2 Click on file -> New -> Website -> Select ASP.NET Web Form Site -> Click on Ok
Default.aspx get created.
Step:-3 Click on Design view.
Step:-4 From Toolbox drag and drop all required Elements and Controls
Step:-5 Then click on source of Default.aspx and write C# code into it.
Step:-6 Run the program.
CONTROL ID VALUE
Labels
Label 1 Name
Label 2 Roll No
Label 3 Course
Label 4 Class
Textbox
Textbox 1 Empty
Textbox 2 Empty
Dropdown List Dropdownlist1
BSC IT
B.com
BMS
RadioButton
RadioButton 1 FY
RadioButton 2 SY
RaddioButton 3 TY
Button Button 1 Submit
Jaspreet Kaur BalAWP217062
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Creating an ASP.NET Web Form with RadioButtons, DropDownList, and Calendar Controls and more Lecture notes Physics in PDF only on Docsity!

PRACTICAL NO-

AIM-create a simple web page with various server controls to demonstrate setting and use of their properties. Steps: Step:-1 Open a Visual studio. Step:-2 Click on file -> New -> Website -> Select ASP.NET Web Form Site -> Click on Ok Default.aspx get created. Step:-3 Click on Design view. Step:-4 From Toolbox drag and drop all required Elements and Controls Step:-5 Then click on source of Default.aspx and write C# code into it. Step:-6 Run the program.

CONTROL ID VALUE

Labels

Label 1 Name

Label 2 Roll No

Label 3 Course

Label 4 Class

Textbox

Textbox 1 Empty

Textbox 2 Empty

Dropdown List Dropdownlist

BSC IT

B.com

BMS

RadioButton

RadioButton 1 FY

RadioButton 2 SY

RaddioButton 3 TY

Button Button 1^ Submit

Default.aspx

<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="practical 3.aspx.cs"Inherits="practical_3"%>

Name :

Roll

Class:

&n bsp;

&n bsp;

Cource:

BSC-IT B.COM BAF

&n bsp; &nbs p;

## B.Demonstrate the use of calendar control to perform following

operations.

(a)Display message in a calendar control

(b) display vacation in calendar control

(c) selected day in calendar control using style dates

(d)difference between two calendar

Steps:

Step:-1 Open a Visual studio. Step:-2 Click on file -> New -> Website -> Select ASP.NET Web Form Site -> Click on Ok

Default.aspx get created. Step:-3 Click on Design Step:-4 From Toolbox drag and drop calendar control Step:-5 Then click on source of Default.aspx and write C# code into it. Step:-6 Run the program.

Controls ID Value

Label Label 1 "Your Selected Date”

Label 2 "Today's Date"

Label 3 "Ganpati Vacation start: 9-2-2019"

Label 4 "Days remaining for Ganpati vacation"

Button Button 1 Result

Button 2 Reset

Calendar control Calendar 1

Default.aspx.cs: using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Web; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; publicpartialclass_Default :Page { protectedvoidPage_Load(object sender, EventArgs e) { } protectedvoid Calendar1_DayRender(objectsender,System.Web.UI.WebControls.DayRender EventArgs e) { if(e.Day.Date.Day==5&&e.Day.Date.Month==9) { e.Cell.BackColor = System.Drawing.Color.Yellow; Label lb1 = newLabel(); e.Cell.Controls.Add(lb1); Image g1 = newImage(); g1.ImageUrl = "td.jpg"; g1.Height = 20; g1.Width = 20; e.Cell.Controls.Add(g1); if(e.Day.Date.Day==13&&e.Day.Date.Month==9) { Calendar1.SelectedDate = newDateTime(2018,9,12); Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate, Calendar1.SelectedDate.AddDays(10)); Label lbl1 = newLabel(); lbl1.Text = "Ganpati!"; e.Cell.Controls.Add(lbl1); } } } protectedvoid Calendar1_SelectionChanged(object sender, EventArgs e) { Label1.Text = "Your Selected Date:" + Calendar1.SelectedDate.Date.ToString(); } protectedvoid Button1_Click(object sender, EventArgs e) { Calendar1.Caption = "CALENDAR 2019"; Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday; Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth; Label2.Text = "Today's Date" + Calendar1.TodaysDate.ToShortDateString(); Label2.Text = "Ganpati Vacation start: 9-2-2019"; TimeSpan d = newDateTime(2019, 9, 2) - DateTime.Now; Label4.Text = "Days remaining for Ganpati vacation:" + d.Days.ToString(); TimeSpan d1 = newDateTime(2019, 9, 2) - DateTime.Now; if(Calendar1.SelectedDate.ToShortDateString()=="9-2-2019") Label3.Text="Ganpati festival start"; if(Calendar1.SelectedDate.ToShortDateString()=="9-12-2019") Label3.Text="Ganpati festival end"; }

Default.aspx.cs: using System; usingSystem.Collections.Generic; usingSystem.Linq;usingSystem.Web; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; public partialclass_Default :Page { protectedvoidPage_Load(object sender, EventArgs e) { } protectedvoid TreeView1_SelectedNodeChanged(object sender, EventArgs e) { Response.Write("You Have selected The Option:" + TreeView1.SelectedValue); } protectedvoid TreeView1_TreeNodeCollapse(object sender, TreeNodeEventArgs e) { Response.Write("The value Collapsed Was:" + e.Node.Value); } }

Output:

Practical No: 4

Aim:CREATE A REGISTRATION FORM TO DEMONSTRATE USE OF VARIOUS VALIDATION CONTROL Steps: Step:-1 Open a Visual studio. Step:-2 Click on file -> New -> Website -> Select ASP.NET Web Form Site -> Click on Ok Default.aspx get created.

Step:-3 Click on Design Step:-4 From Toolbox drag and drop all required Elements and Controls Step:-5 Then click on source of Default.aspx and write C# code into it. Step:-6 Run the program.

Controls ID Value Types of validations

Labels Label 1 Name Label 2 Phone No Label 3 E-mail id Label 4 Password

Default.aspx <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

Output :

B.CREATE WEB FORM TO DEMONSTRATE USE OF ADROTATOR CONTROLS.

Steps: Step:-1 Open a Visual studio. Step:-2 Click on file -> New -> Website -> Select ASP.NET Web Form Site -> Click on Ok Default.aspxgetcreated.

Step:-3 Right click on website -> Add -> Add new item -> Select XMLFILE.xml Step:-4 Write XML code into XMLFile.xml Step:-5 Click on Design of Default.aspx. Step:-6 From Toolbox drag and drop Ad Rotator. Step:-7 Now go to the properties of Ad Rotator and select AdvertisementFile as XMLFILE.xml Step:-8 Run the program.

Default.aspx <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

File.xml

http://localhost:61398/download (1).jfif 20

http://localhost:61398/download.jfif 20

Output:

Web user control ascx.cs using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Web; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; public partial class WebUserControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label3.Text = "Your Name is " + TextBox1.Text + " and you are from " + TextBox2.Text; } } Output: