0% found this document useful (0 votes)
12 views87 pages

6429 AWP Journal

The document outlines a curriculum for the T.Y. B.Sc. (I.T.) program at Ramniranjan Jhunjhunwala College, focusing on Advanced Web Programming using C# and ASP.NET. It includes a series of practical assignments covering topics such as basic C# applications, object-oriented programming, web forms, user controls, database interactions, and AJAX. Each section specifies tasks, dates, and sample code for students to complete, demonstrating various programming concepts and techniques.

Uploaded by

kakashihata932
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views87 pages

6429 AWP Journal

The document outlines a curriculum for the T.Y. B.Sc. (I.T.) program at Ramniranjan Jhunjhunwala College, focusing on Advanced Web Programming using C# and ASP.NET. It includes a series of practical assignments covering topics such as basic C# applications, object-oriented programming, web forms, user controls, database interactions, and AJAX. Each section specifies tasks, dates, and sample code for students to complete, demonstrating various programming concepts and techniques.

Uploaded by

kakashihata932
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 87

RAMNIRANJAN JHUNJHUNWALA COLLEGE

GHATKOPAR (W), MUMBAI - 400 086

DEPARTMENT OF INFORMATION
TECHNOLOGY
2024- 2025

T.Y. B.Sc. ( I.T.)


Advance Web Programming(AWP)

Name : - Nilesh Kannaujiya


Roll No: - 6429
SR NO. TOPIC DATE

1. Working with basic C# and ASP .NET

Create an application that obtains four int values from the user
a. and displays the product. 25/6/2024
Create an application that receives the (Student Id, Student
b. Name, Course Name, Date of Birth) information from a set of 25/6/2024
students. The application should also display the information of
all the students once the data entered.
2. Working with Object Oriented C# and ASP .NET

Create simple application to perform money conversion


a. 02/7/2024
Create simple application to perform temperature conversion
b. 02/7/2024

3. Working with Web Forms and Controls


Demonstrate the use of Calendar control to perform following
a. operations. 09/7/2024
a) Display messages in a calendar control
b) Display vacation in a calendar control
c) Selected day in a calendar control using style
d) Difference between two calendar dates
Demonstrate the use of Treeview control performs the
b. following operations. 09/7/2024
a) Treeview control and datalist
b) Treeview operations

4. Working with Form Controls

a. Create a registration form to demonstrate use of various 16/7/2024


Validation controls.

b. Create a web form to demonstrate use of Adrotator Control. 16/7/2024

5. Working with User Control

a. Create a web form to demonstrate use of User Controls. 23/7/2024

6. Working with Navigation, Beautification and Master page.

a. Create a web application to demonstrate use of Master Page 23/7/2024


with applying Styles and Themes for page beautification.

7. Working with Database

a. Create a web application bind data in a multiline textbox by 06/8/2024


querying in another textbox.

b. Create a web application to display records using database. 13/08/2024

8. Working with data controls

a. Demonstrate the use of DataList Link Control. 13/08/2024

b. Create a web application to display Data Binding using 20/8/2024


Dropdownlist control

c. Create a web application for inserting and deleting record from 20/8/2024
database.(Using Execute-Non Query)

9. Working with GridView control


Create a web application to demonstrate use of GridView
a. button column and GridView events.
Create a web application to demonstrate GridView paging and
b. Create your own table format using GridView. 03/9/2024

10 Working with AJAX and XML


Create a web application to demonstrate reading and writing
a. operations with XML. 30/8/2024
Create a web application to demonstrate use of various Ajax
b. controls.

Practical No:1

➡Working with basic C# and ASP.NET


(a):Create an application that obtains four int values from the user and displays
the product.
Design:
Output:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void TextBox1_TextChanged(object sender, EventArgs e)


{

protected void Button1_Click(object sender, EventArgs e)


{
int a, b, c, d;
a = Convert.ToInt16(TextBox1.Text);
b = Convert.ToInt16(TextBox2.Text);
c = Convert.ToInt16(TextBox3.Text);
d = Convert.ToInt16(TextBox4.Text);
int product = num1 * num2 * num 3* num4;
TextBox5.Text = product.ToString();
}
}
}
(b)Create an application that receives the (Student Id, Student Name, Course
Name, Date of Birth) information from a set of students. The application should
also display the information of all the students once the data entered.
Design:

Code:
Output:
(C):Check whether the given number is prime or not

INPUT :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_Prime
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
int num, i;
bool isPrime = true;
num = int.Parse(TextBox1.Text);

if (num <= 1)
{
TextBox2.Text = num + " is neither prime nor composite ";
return;
}

for (i = 2; i < num; i++)


{
if (num % i == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
{
TextBox2.Text = num + " is a prime number ";
}
else
{
TextBox2.Text = num + " is not a prime number ";
}
}
}
}

OUTPUT :

For Input value 1:

For Input value 2:

For Input value 4:

Practical No:2
Working with Object Oriented C# and ASP .NET

(a)Create simple application to perform money conversion

Money Convertor

INPUT :

using System;

public class CurrencyConverter


{
public double dollars, euros, rupees;

public CurrencyConverter()
{
dollars = 0;
euros = 0;
rupees = 0;
}

// Convert Dollars to Rupees


public void convertDollarsToRupees()
{
double exchangeRate = 83.52;
rupees = dollars * exchangeRate;
}

// Convert Rupees to Dollars


public void convertRupeesToDollars()
{
double exchangeRate = 83.52; // Assuming the same exchange rate for
symmetry
dollars = rupees / exchangeRate;
}

// Convert Euros to Rupees


public void convertEurosToRupees()
{
double exchangeRate = 90.37;
rupees = euros * exchangeRate;
}

// Convert Rupees to Euros


public void convertRupeesToEuros()
{
double exchangeRate = 90.58;
euros = rupees / exchangeRate;
}
}
namespace 6429
{
public partial class WebForm1 : System.Web.UI.Page
{
CurrencyConverter converter;

protected void Page_Load(object sender, EventArgs e)


{
converter = new CurrencyConverter();
}

protected void RadioButton1_CheckedChanged(object sender,


EventArgs e)
{
if (RadioButton1.Checked)
{
double val = Double.Parse(TextBox1.Text);
converter.dollars = val;
converter.convertDollarsToRupees();
Response.Write(val + " Dollar(s) to Rupees " + converter.rupees);
}
}

protected void RadioButton2_CheckedChanged(object sender,


EventArgs e)
{
if (RadioButton2.Checked)
{
double val = Convert.ToDouble(TextBox1.Text);
converter.rupees = val;
converter.convertRupeesToDollars();
Response.Write(val + " Rupee(s) to Dollars: " + converter.dollars);
}
}

protected void RadioButton3_CheckedChanged(object sender,


EventArgs e)
{
if (RadioButton3.Checked)
{
double val = Convert.ToDouble(TextBox1.Text);
converter.euros = val;
converter.convertEurosToRupees();
Response.Write(val + " Euro(s) to Rupees: " + converter.rupees);
}
}

protected void RadioButton4_CheckedChanged(object sender,


EventArgs e)
{
if (RadioButton4.Checked)
{
double val = Convert.ToDouble(TextBox1.Text);
converter.rupees = val;
converter.convertRupeesToEuros();
Response.Write(val + " Rupee(s) to Euros: " + converter.euros);
}
}
}
}
OUTPUT :

Dollars to Rupees :

Rupees to Dollars :
Euros to Rupees :

Rupees to Euro :

(b)Create simple application to perform temperature conversion


Temperature convertor

INPUT :

using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public class convertTemp


{
public float faren, celsius;
public convertTemp()
{
faren = 0; celsius = 0;
}
public void convertToFaren()
{
faren=((celsius*9.0f/5.0f)+36.05f);
}
public void convertToCelsius()
{
celsius = (faren - 32) * (5.0f / 9.0f);
}
}

namespace 6429
{
public partial class WebForm1 : System.Web.UI.Page
{
convertTemp c;
protected void Page_Load(object sender, EventArgs e)
{
c = new convertTemp();
}
protected void Button1_Click(object sender, EventArgs e)
{
char ch;
ch = Convert.ToChar(TextBox1.Text);
if (ch == 'c')
{
c.celsius = float.Parse(TextBox2.Text);
c.convertToFaren();
TextBox3.Text= "celsius to faren "+c.faren;
}
if (ch == 'f')
{
c.faren = float.Parse(TextBox2.Text);
c.convertToCelsius();
TextBox3.Text = " faren to celsius " + c.celsius;
}

}
}
}

OUTPUT :

Faren to Celsius :

Celsius to Faren :

Practical No:3
Working with Web Forms and Controls

A)Demonstrate the use of Calendar control to perform following operations.


a) Display messages in a calendar control
b) Display vacation in a calendar control
c) Selected day in a calendar control using style
d) Difference between two calendar dates

INPUT:

WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_3_A
{
public partial class Nilesh_Calendar : System.Web.UI.Page
{
protected void Calendar1_DayRender(Object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 9)
{
e.Cell.BackColor = System.Drawing.Color.Yellow;
Label lbl = new Label();
lbl.Text = "<br>Teachers Day</br>";
e.Cell.Controls.Add(lbl);
}
if (e.Day.Date.Day == 13 && e.Day.Date.Month == 9)
{
Calendar1.SelectedDate = new DateTime(2024, 9, 12);
Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label();
lbl1.Text = "<br> Ganpati ";
e.Cell.Controls.Add(lbl1);
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Label1.Text = "Your Selected Date " +
Calendar1.SelectedDate.Date.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;
Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;
Calendar1.TitleFormat = TitleFormat.Month;
Label2.Text = "Today's Date: " + Calendar1.TodaysDate.ToShortDateString();
Label3.Text = "Ganpati vacation start: 07-09-2024";
TimeSpan d = new DateTime(2024, 9, 7) - Calendar1.SelectedDate;
Label4.Text = "Days remaining for Ganpati Vacation: " + d.Days.ToString();
TimeSpan d1 = new DateTime(2024, 12, 31) - Calendar1.SelectedDate;
Label5.Text = "Days remaining for New Year: " + d1.Days.ToString();
if (Calendar1.SelectedDate.ToShortDateString() == "7-9-2024")
Label3.Text = "<br>Ganpati Festival Start</br>";
if (Calendar1.SelectedDate.ToShortDateString() == "16-9-2024")
Label3.Text = "<br>Ganpati Festival End</br>";
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
Label4.Text = "";
Label5.Text = "";
Calendar1.SelectedDates.Clear();
}
}
}

OUTPUT:

On click of Submit:
On click of Reset:
B)Demonstrate the use of Treeview control performs the following operations.
a) Treeview control and datalist
b) Treeview operations

DESIGN:
INPUT:

Tree_Structure.aspx :
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Tree_Structure.aspx.cs"
Inherits="Tree_Structure_6429.Tree_Structure" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode
ImageUrl="https://www.tutorialspoint.com/computer_programming/index.htm"
Text="PROGRAMMING LANGUAGES" Value="PROGRAMMING
LANGUAGES">
<asp:TreeNode NavigateUrl="https://www.w3schools.com/cpp/"
Text="C++" Value="C++"></asp:TreeNode>
<asp:TreeNode NavigateUrl="https://www.w3schools.com/java/"
Text="JAVA" Value="JAVA"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode NavigateUrl="https://www.javatpoint.com/operating-
system" Text="OPERATING SYSTEM" Value="OPERATING SYSTEM">
<asp:TreeNode
NavigateUrl="https://www.microsoft.com/en-in/windows?r=1"
Text="WINDOWS" Value="WINDOWS"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://support.apple.com/en-in/macos" Text="MAC"
Value="LINUX"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<asp:Label ID="Label1" runat="server" Text="Fetch data list Using XML
Data :"></asp:Label>
<div>
<asp:DataList ID="DataList1" runat="server"
OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<table class="table" border="1">
<tr>
<td>Roll Num : <%#Eval("sid") %><br/>
Name : <%#Eval("sname") %>
Class : <%#Eval("sclass") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>

Tree_Structure.aspx.cs :
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Tree_Structure_6429
{
public partial class Tree_Structure : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
protected void BindData()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Tree_Structure.xml"));
if(ds!=null && ds.HasChanges())
{
DataList1.DataSource = ds;
DataList1.DataBind();

}
else
{
DataList1.DataBind();
}

}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs
e)
{

}
}
}

Tree_Structure.xml :
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1</sid>
<sname>Pratham</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>2</sid>
<sname>Nilesh</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>3</sid>
<sname>Devdas</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>4</sid>
<sname>Chetan</sname>
<sclass>TYIT</sclass>
</student>
</studentdetail>

OUTPUT:

Practical No:4

Working with Form Control


A)Create a registration form to demonstrate use of various Validation controls.

INPUT :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 6429_Validation
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
Response.Write("Your response have been recorded ");
}
}
}

OUTPUT :
B)Create a web form to demonstrate use of Adrotator Control.

DESIGN:
WebForm1.aspx.cs:
INPUT :

<?xml version="1.0" encoding="utf-8" ?>


<Advertisements>
<Ad>
<ImageUrl>facebook.jpg</ImageUrl>
<NavigateUrl>https://www.facebook.com/</NavigateUrl>
<AlternateText>Facebook</AlternateText>
<Impressions>20</Impressions>
<Keyword>facebook</Keyword>
</Ad>
<Ad>
<ImageUrl>instagram.jpg</ImageUrl>

<NavigateUrl>https://www.instagram.com/accounts/login/</NavigateUrl>
<AlternateText>Instagram</AlternateText>
<Impressions>20</Impressions>
<Keyword>instagram</Keyword>
</Ad>
<Ad>
<ImageUrl>whatsapp.png</ImageUrl>
<NavigateUrl>https://www.whatsapp.com/</NavigateUrl>
<AlternateText>WhatsApp</AlternateText>
<Impressions>20</Impressions>
<Keyword>whatsapp</Keyword>
</Ad>
<Ad>
<ImageUrl>telegram.jpg</ImageUrl>
<NavigateUrl>https://web.telegram.org/k/</NavigateUrl>
<AlternateText>Telegram</AlternateText>
<Impressions>20</Impressions>
<Keyword>telegram</Keyword>
</Ad>
</Advertisements>

OUTPUT :
Practical No.05

Working with User Control

A)Create a web form to demonstrate use of User Controls.

DESIGN:

INPUT:

WebUserControl1.ascx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="_6429_Niles.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Name <asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox><br />

City <asp:TextBox ID="TextBox1"


runat="server"></asp:TextBox><br />

<asp:Button ID="Button1" runat="server" Text="Button"


OnClick="Button1_Click" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br
/>

</div>

</form>
</body>
</html>

Webform.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_Niles
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "My Name is " + TextBox2.Text + " I am from " +
TextBox1.Text;
}
}
}
WebForm1.aspx:
<<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc"
TagName="Student" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc:Student ID="studentcontrol" runat="server" />
</div>
</form>
</body>
</html>
Just add the above highlighted line in the “WebForm1.aspx” file to connect the
user control with the web Form.
OUTPUT:
PRACTICAL NO.06

Working with Navigation, Beautification and Master page.

A)Create a web application to demonstrate use of Master Page with applying


Styles and Themes for page beautification.

INPUT:
Site1.Master:
<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" Inherits="_6429_MasterPage.Site1" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Different Programming Languages</h1>
<a href="WebForm1.aspx">C Sharp</a>
<a href="WebForm4.aspx">Java</a>
<a href="WebForm5.aspx">Javascript</a>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>

</div>
</form>
</body>
</html>
WebForm1.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"


AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="_6429_MasterPage.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<h1>C Sharp Language</h1>
<p style="font-size:20px">
C# is pronounced as "C-Sharp". It is an object-oriented programming
language provided by Microsoft that runs on .Net Framework.
C# tutorial provides basic and advanced concepts of C#. Our C# tutorial is
designed for beginners and professionals.

C# is a programming language of .Net Framework.

Our C# tutorial includes all topics of C# such as first example, control


statements, objects and classes, inheritance, constructor,
destructor, this, static, sealed, polymorphism
abstraction, abstract class, interface, namespace, encapsulation, properties,
indexer, arrays, strings, regex, exception handling, multithreading,
File IO, Collections etc.

</p>
</asp:Content>
WebForm4.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"


AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs"
Inherits="_64843_MasterPage.WebForm4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<h1>Java Language</h1>
<p style="font-size:20px">
Java is a programming language and a platform. Java is a high level, robust,
object-oriented and secure programming language.
Our core Java programming tutorial is designed for students and working
professionals. Java is an object-oriented, class-based,
concurrent, secured and general-purpose computer-programming language. It
is a widely used robust technology.
</p>
</asp:Content>
WebForm5.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"


AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs"
Inherits="_6429_MasterPage.WebForm5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<h1>Javascript Language</h1>
<p style="font-size:20px">
JavaScript (js) is a light-weight object-oriented programming language
which is used by several websites for scripting the webpages.
It is an interpreted, full-fledged programming language that enables
dynamic interactivity on websites when applied to an HTML document.
Our JavaScript Tutorial is designed for beginners and professionals both.
JavaScript is used to create client-side dynamic pages.

JavaScript is an object-based scripting language which is lightweight and


cross-platform.

JavaScript is not a compiled language, but it is a translated language. The


JavaScript Translator (embedded in the browser) is responsible
for translating the JavaScript code for the web browser.
</p>
</asp:Content>
OUTPUT:

After clicking on WebForm1 link that is on C Sharp:

After clicking on WebForm4 link that is on Java:

After clicking on WebForm5 link that is on Javascript:

Below is the Master page output which will be displayed on all the
WebForm Pages no separate page is there as it is the master page :

PRACTICAL NO.07
Working with Database

A)Create a web application bind data in a multiline textbox by querying in


another textbox

INPUT:
Creating database name tyit and table Student in that database-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="sqlServerOverview.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"
OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:StudentConnectionString %>" ProviderName="<%$
ConnectionStrings:StudentConnectionString.ProviderName %>" SelectCommand="SELECT
* FROM [tyit]"></asp:SqlDataSource>

</div>
</form>
</body>
</html>

Note
Data Source=.;Initial Catalog=Student;Integrated Security=True;Trust Server
Certificate=True

StudentConnectionString
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

namespace WebApplication20
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Xml.file1.xml"));
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();

protected void Button2_Click(object sender, EventArgs e)


{
using (XmlWriter xmlW = XmlWriter.Create("C:\\Users\\Admin\\source\\repos\\
WebApplication20\\XMLFile1.xml"))
{
xmlW.WriteStartElement("Student");
xmlW.WriteElementString("Name", "Nilesh");
xmlW.WriteElementString("Age", "22");
xmlW.WriteEndElement();
}
Response.Write("Ok");
}
}
}
}

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"


Inherits="WebApplication20.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Read XML" OnClick="Button1_Click"
/>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name"></asp:BoundField>
<asp:BoundField DataField="Age" HeaderText="Age"></asp:BoundField>
</Columns>
</asp:GridView>
<asp:Button ID="Button2" runat="server" Text="Write XML"
OnClick="Button2_Click"/>
</div>
</form>
</body>
</html>
STEPS TO FOLLOW IN DESIGN:
For ListBox:

Do the below changes in web.config file:

The size of ListBox is increased because I had added the height in its tag:

<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1"


DataTextField="ID" DataValueField="ID" height="320px"></asp:ListBox>
WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_7_A
{
public partial class WebForm1 : System.Web.UI.Page
{

protected void Button1_Click(object sender, EventArgs e)


{
string constr =
ConfigurationManager.ConnectionStrings["NileshConnectionString"].ConnectionStrin
g;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand(TextBox1.Text, con);
SqlDataReader reader = cmd.ExecuteReader();
ListBox1.Items.Clear();
while (reader.Read())
{
//To add new blank line in the text area
for (int i = 0; i < reader.FieldCount - 1; i++)
{
ListBox1.Items.Add(reader[i].ToString());
}
}
reader.Close();
con.Close();

}
}
}
OUTPUT:
B)Create a web application to display records using a database.

DESIGN:

INPUT:

WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_7_B
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
String TYIT_6429ConnectionString =
ConfigurationManager.ConnectionStrings["NileshConnectionString"].Connecti
onString;
SqlConnection con = new
SqlConnection(TYIT_6429ConnectionString );
SqlCommand cmd = new SqlCommand("Select ID,FirstName from
Student", con);
con.Open();
SqlDataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
Label1.Text += "<br>"+reader["ID"].ToString() + " " +
reader["FirstName"].ToString()+"<br>";

}
}
}

OUTPUT:
PRACTICAL NO.08

Working with data controls

A)Demonstrate the use of DataList Link Control.

No code for these practical just follow below steps on design:

DESIGN:

STEPS TO FOLLOW IN DESIGN:


After that click on finish you will get below output:
OUTPUT:

On INPUT Screen:

On Browser:
B)Create a web application to display Data Binding using Dropdownlist
control
DESIGN:

INPUT:

WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_8_B
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string connStr =
ConfigurationManager.ConnectionStrings["NileshConnectionString"].Connecti
onString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct FirstName
from Student", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "FirstName";
DropDownList1.DataBind();
reader.Close();
con.Close();
}
}

protected void Button1_Click1(object sender, EventArgs e)


{
Label1.Text = "Student name is : " + DropDownList1.SelectedValue;

}
}
}
OUTPUT:
C)Create a web application for inserting and deleting records from the database.
(Using Execute-Non Query)

DESIGN:

INPUT:

WebForm1.aspx.cs:
using System;

using System.Collections.Generic;

using System.Configuration;

using System.Data.SqlClient;

using System.Linq;

using System.Reflection.Emit;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace _6429_8_C

{
public partial class WebForm1 : System.Web.UI.Page

protected void Button1_Click(object sender, EventArgs e)

string collegeConnectionString =
ConfigurationManager.ConnectionStrings["NileshConnectionString"].ConnectionStri
ng;

SqlConnection con = new SqlConnection(collegeConnectionString);

string InsertQuery = "insert into Student values(@ID, @FirstName,


@LastName, @Age)";

SqlCommand cmd = new SqlCommand(InsertQuery, con);

cmd.Parameters.AddWithValue("@ID", TextBox1.Text);

cmd.Parameters.AddWithValue("@FirstName", TextBox2.Text);

cmd.Parameters.AddWithValue("@LastName", TextBox3.Text);

cmd.Parameters.AddWithValue("@Age", TextBox4.Text);

con.Open();

cmd.ExecuteNonQuery();

Label5.Text = "Record Inserted Successfully!!";

con.Close();

protected void Button2_Click(object sender, EventArgs e)

string collegeConnectionString =
ConfigurationManager.ConnectionStrings["NileshConnectionString"].ConnectionStri
ng;

SqlConnection con = new SqlConnection(collegeConnectionString);

string InsertQuery = "delete from Student where FirstName=@FirstName";

SqlCommand cmd = new SqlCommand(InsertQuery, con);


cmd.Parameters.AddWithValue("@FirstName", TextBox2.Text);

con.Open();

cmd.ExecuteNonQuery();

Label5.Text = "Record Deleted Successfully!!";

con.Close();

}
OUTPUT:

For Inserting-

In sql server Management Studio:


For Deleting-

In sql server Management Studio:


PRACTICAL NO.09

Working with GridView control

A)Create a web application to demonstrate use of GridView button column and


GridView events.

DESIGN:
Before this add the connection string in GridView Control and make the
changes in web.config file make ssl certificate yes instead of true by removing
all the spaces.

STEPS TO FOLLOW TO GET THE ABOVE IMAGE DESIGN:

CHOOSE NEW DATA SOURCE


OUTPUT:
B)Grid view for just showing table with update ,edit and delete option:

DESIGN:

STEPS TO FOLLOW TO GET THESE DESIGN:

CHOOSE NEW DATA SOURCE


Check the insert,update and delete statements and then ok:

Click next and then test query

Enable all the option in grid view control:


Do change the below line in web.config file:
OUTPUT:
Updating the Table Changing the firstname and lastname from table of id 1 and
then click update:

Deleting the row with id one by clicking on delete


After that that row will be deleted:
PRACTICAL NO.10

Working with AJAX and XML

A)Create a web application to demonstrate reading and writing operations with


XML.

DESIGN:

INPUT:

WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data;

namespace _6429_10_A
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("XMLFile1.xml"));
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();

protected void Button2_Click(object sender, EventArgs e)


{
using (XmlWriter xmlW =
XmlWriter.Create(@"C:\Users\Admin\source\repos\6429\
XMLFile2.xml"))
{
xmlW.WriteStartElement("Student");
xmlW.WriteElementString("Name", "Nilesh");
xmlW.WriteElementString("Age", "22");
xmlW.WriteEndElement();
}
Response.Write("OK");

}
}
}
XMLFile1.xml:
<?xml version="1.0" encoding="utf-8" ?>
<student>
<name>Devdas</name>
<age>19</age>
</student>
In the below GridView go to edit columns and then BoundField give
HeaderText and DataField value of GridView Control
OUTPUT:

After click of Read Button:

After click of Write Button:

The entry get entered in XMLFile2.xml:


B)Create a web application to demonstrate use of various Ajax controls.

DESIGN:

INPUT:
WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _6429_10_B
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
String time = DateTime.Now.ToLongTimeString();
Label2.Text = "Showing time from partial pannel" + time;
}
protected void Button2_Click(object sender, EventArgs e)
{
String time = DateTime.Now.ToLongTimeString();
Label3.Text = "Showing time from Total pannel" + time;
}
}
}

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy