Practical - 03

AIM: Design a web application to generate a mark sheet of a student using ASP.Net through C# language.

How to open Visual Studio

Visual Studio Framework

Framework Introduction

Figure 1: Introduction of Visual Studio Framework.

Discussion

Here, the aim is to design a mark sheet where user will enter the marks of any five subjects and application will generate result by stating total marks, percentage and grade.

Design view of this is shown in Figure 2 and its HTML code is shown in Figure 3.

Design View of Marksheet

Design View

Figure 2: Design view of Mark sheet.

HTML code of Marksheet Web Form

HTML Code

Figure 3: HTML code of web form of Mark Sheet.

C# Code

Here, two buttons are design, 1 - to clear all data on page. 2 - to display marksheet result. C# code of above design is shown below.

			
protected void Button1_Click(object sender, EventArgs e)
{
        TextBox1.Text = string.Empty;
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
        TextBox5.Text = "";
        Label9.Text = "";
        Label2.Text = "";
        Label3.Text = "";
        Label4.Text = "";
        Label5.Text = "";
        Label6.Text = "";
        Label7.Text = "";
        Label8.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
        int Total, English_Marks = 0, Hindi_Marks = 0, Maths_Marks = 0, Science_Marks = 0, Computer_Marks = 0;
        float Percentage;
        char Grade;
        if (!int.TryParse(TextBox1.Text, out English_Marks))
        {
            Label5.Text = "InValid Marks hence Consider 0";
        }
        if (!int.TryParse(TextBox2.Text, out Hindi_Marks))
        {
            Label6.Text = "InValid Marks hence Consider 0";
        }
        if (!int.TryParse(TextBox3.Text, out Maths_Marks))
        {
            Label7.Text = "InValid Marks hence Consider 0";
        }
        if (!int.TryParse(TextBox4.Text, out Science_Marks))
        {
            Label8.Text = "InValid Marks hence Consider 0";
        }
        if (!int.TryParse(TextBox5.Text, out Computer_Marks))
        {
            Label9.Text = "InValid Marks hence Consider 0";
        }

        Total = English_Marks + Hindi_Marks + Maths_Marks + Science_Marks + Computer_Marks;
        Percentage = (Total * 100) / 500.0f;
        if (Percentage > 80)
        {
            Grade = 'A';
        }
        else if (Percentage > 60)
        {
            Grade = 'B';
        }
        else if (Percentage >= 35)
        {
            Grade = 'C';
        }
        else
        {
            Grade = 'F';
        }
        Label2.Text = Total.ToString() + "/500";
        Label3.Text = Percentage.ToString() + "%";
        Label4.Text = Grade.ToString() + " Grade";

}
					

Points to Remember:

Theory of Computation AIM 01 Transition Diagram

Prepared By

Piyush Garg,
Asst. Professor,
Department of CSE, CIST
E-mail: piyushgarg1985@yahoo.com