View
View
View
View :
Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Output :
2. Write an Asp.Net Program to Create Simple Web Application using two or more web
form.
View :
First web form
code :
}
protected void tnsubmit_Click(object sender, EventArgs e)
{
Response.Redirect("~/Second.aspx");
}
protected void btnsubmit1_Click(object sender, EventArgs e)
{
Server.Transfer("~/Second.aspx");
}
}
Output :
3. Write an Asp.Net program using while or for loop to print sum of first 100 ODD and Even
Numbers.
View :
code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Output :
4. Write an Asp.Net Program to add the value of Text Box in to Dropdown List and List box
Controls.
View :
if (!string.IsNullOrEmpty(textBoxValue))
{
DropDownList1.Items.Add(new ListItem(textBoxValue));
ListBox2.Items.Add(textBoxValue);
TextBox1.Text = string.Empty;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void ddlItems_SelectedIndexChanged(object sender, EventArgs e)
{
// Handle DropDownList selection change if needed
}
protected void btnDeleteFromDropDown_Click(object sender, EventArgs e)
{
// Delete selected item from DropDownList
if (ddlItems.SelectedIndex != -1)
{
ddlItems.Items.RemoveAt(ddlItems.SelectedIndex);
}
}
protected void btnDeleteFromListBox_Click(object sender, EventArgs e)
{
// Delete selected items from ListBox
for (int i = lstItems.Items.Count - 1; i >= 0; i--)
{
if (lstItems.Items[i].Selected)
{
lstItems.Items.RemoveAt(i);
}
}
}
}
Output :
5. Write an Asp.Net Program to set Image on Image Control according to selection of image
name from Dropdown list.
View :
code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Code :
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="home2.master.cs"
Inherits="home2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td colspan="2" height="150px" align="center" bgcolor="#CC33FF">
<b> YASHWANTRAO CHAVAN MAHAVIDYALAYA</b></br>
URUN-ISLAMPUR</td>
</tr>
<tr>
<td colspan="2">
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/aboutus.aspx" Text="about us" Value="about us">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/contact.aspx" Text="contact us" Value="contact us">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/registration.aspx" Text="registration"
Value="registration"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/photo.aspx" Text="photo" Value="photo">
<asp:MenuItem NavigateUrl="~/sports.aspx" Text="sports" Value="sports">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/annualfunction.aspx" Text="annual function"
Value="annual function"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td height="200px" width="30%">
NEWS AND EVENTS</td>
<td>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<b> developed by sanika</b></td>
</tr>
</table>
</form>
</body>
</html>
Output :
About us page :
Contact page :
7. Program to demonstrate client side state management and Server side management.
View :
Client side management
Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
}
protected void TextBox5_TextChanged(object sender, EventArgs e)
{
}
protected void btnsave_Click(object sender, EventArgs e)
{
con.Open();
s = "insert into studentinfo(rollno,sname,sclass,smob,semail)values('" + Txtroll.Text + "','" +
Txtname.Text + "','" + Txtclass.Text + "','" + Txtmob.Text + "','" + txtemail.Text + "')";
cmd = new SqlCommand(s, con);
i = cmd.ExecuteNonQuery();
if (i > 0)
{
lblmsg.Text = "record save";
}
else
{
lblmsg.Text = "record not save";
}
con.Close();
}
protected void btnupdate_Click(object sender, EventArgs e)
{
con.Open();
s = "update studentinfo set sname='" + Txtname.Text + "', sclass='" + Txtclass.Text + "', smob='"
+ Txtmob.Text + "', semail='" + txtemail.Text + "' where rollno=" + Txtroll.Text + "";
cmd = new SqlCommand(s, con);
i = cmd.ExecuteNonQuery();
cmd.ExecuteReader();
if (i > 0)
{
lblmsg.Text = "record update";
}
else
{
lblmsg.Text = "record not update ";
}
con.Close();
}
protected void btndelete_Click(object sender, EventArgs e)
{
con.Open();
s = "delete from studentinfo where rollno='" + Txtroll.Text + "'";
cmd = new SqlCommand(s, con);
i = cmd.ExecuteNonQuery();
if (i > 0)
{
lblmsg.Text = "record delete";
}
else
{
lblmsg.Text = "record not delete";
}
con.Close();
}
protected void btndisplay_Click(object sender, EventArgs e)
{
s = "select * from studentinfo where sclass='"+Txtclass .Text +"' ";
da = new SqlDataAdapter(s, con);
dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
//con.Open();
//s = "select count(*) from studentinfo ";
//cmd = new SqlCommand(s, con);
//i = Convert.ToInt16(cmd.ExecuteScalar());
//Response.Write(i);
//con.Close();
}
}
}
Output :