Está en la página 1de 5

ICLE's Motilal Jhunjhunwala College of Arts, Commerce & Science

2017-18
PRACTICAL NO. 3-Programs using different server controls

a) AIM: Design a data entry form for student record.It should accept Roll no, Name, Address, Class, Total Marks,
Out of Marks. It should calculate percentage and Grade. Also add these records to listbox

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

public partial class_Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
Label1.Text = (Convert.ToDouble(TextBox4.Text) / Convert.ToDouble(TextBox5.Text) * 100).ToString();
double per = Convert.ToDouble(Label1.Text);
if (per >= 70)
Label2.Text = "O grade";
elseif (per >= 60)
Label2.Text = "A grade";
elseif (per >= 55)
Label2.Text = "B grade";
elseif (per >= 50)
Label2.Text = "C grade";
elseif (per >= 45)
Label2.Text = "D grade";
elseif (per >= 40)
Label2.Text = "E grade";
else
Label2.Text = "F grade";
ListBox1.Items.Add(TextBox2.Text + " " + Label2.Text);

OUTPUT:
ICLE's Motilal Jhunjhunwala College of Arts, Commerce & Science
2017-18
ICLE's Motilal Jhunjhunwala College of Arts, Commerce & Science
2017-18

b) AIM: Write a program to redirect the page to another site using ASP.NET

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

public partial class Default2 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.iclesmj.edu.in/");
}
protected void Button2_Click(object sender, EventArgs e)
{
Server.Transfer("Default.aspx");
}
}

OUTPUT:
ICLE's Motilal Jhunjhunwala College of Arts, Commerce & Science
2017-18
c) AIM: Write a program to demonstrate the use of Rich controls such as Calender control OR

Write an application that receives the following information from a set of students:
Student Id:Student Name:Course Name:Date of Birth:
The application should also display the information of all the students in textbox or label once user click on
submit. Implement this using web server control.

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

public partial classDefault3 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text + " " + TextBox2.Text + " " + DropDownList1.SelectedItem.Text + " " +
Calendar1.SelectedDate.Date.ToString();
}
}

OUTPUT:
ICLE's Motilal Jhunjhunwala College of Arts, Commerce & Science
2017-18
d) AIM: Write a program to demonstrate the use of AutoPostback OR

Design a webpage using CheckBox and a panel control . Place two textboxes i.e textbox1 and textbox2 and a
Button control inside the panel so that on click of this button the factorial of the value provided in the textbox1
will get display in textbox2. Set the visible property of panel control to false. Write the C# code to make the panel
visible on the checkedchanged event of CheckBox so that the factorial operation can be performed.

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

public partial class Default5 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
int num;
num = Convert.ToInt32(TextBox1.Text);
int fact = num;
for (int i = num-1; i>=1; i--)
{
fact = fact * i;
}
TextBox2.Text = fact.ToString();
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
Panel1.Visible = true;
else
Panel1.Visible = false;
}}

También podría gustarte