net 1,2,8

 online examination system


Site1.master

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


<!DOCTYPE html>

<style>

    body {font-family: Arial, sans-serif; 

    margin: 0; 

    padding: 0; 

    text-align: center; 

.header { 

    background: #004080; 

    color: white; 

    padding: 15px; 

.footer { 

    background: #222; 

    color: white; 

    padding: 10px; 

    position: absolute; 

    bottom: 0; 

    width: 100%; 

nav a { 

    color: white; 

    text-decoration: none; 

    margin: 0 10px; 


</style>


<html>

<head>

    <title>Online Examination System</title>

    <link rel="stylesheet" type="text/css" href="Styles.css" />

</head>

<body>

    <form id="Form1" runat="server">

        <div class="header">

            <h1>Online Examination System</h1>

            <nav>

                <a href="Default.aspx">Home</a> |

                <a href="Exam.aspx">Take Exam</a> |

                <a href="Result.aspx">View Result</a>

            </nav>

        </div>

        <asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>

        <div class="footer">&copy; 2025 Online Examination System</div>

    </form>

</body>

</html>


Default.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication20.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Welcome to the Online Examination System</h2>

    <p>Test your knowledge with our online quizzes.</p>

</asp:Content>


Exam.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Exam.aspx.cs" Inherits="WebApplication20.WebForm2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

     <h2>Online Exam</h2>

    <asp:Label ID="lblQuestion" runat="server" Text="Question 1: What is 2 + 2?" /><br /><br />

    <asp:RadioButtonList ID="rblAnswers" runat="server">

        <asp:ListItem Value="3">3</asp:ListItem>

        <asp:ListItem Value="4">4</asp:ListItem>

        <asp:ListItem Value="5">5</asp:ListItem>

        <asp:ListItem Value="6">6</asp:ListItem>

    </asp:RadioButtonList>

    <br />

    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

</asp:Content>


Result.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Result.aspx.cs" Inherits="WebApplication20.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Exam Result</h2>
    <asp:Label ID="lblResult" runat="server" Text="Your score will be displayed here." />
</asp:Content>

Exam.aspx.cs

namespace WebApplication20
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int score = 0;
            if (rblAnswers.SelectedValue == "4") // Check if the selected answer is correct
            {
                score = 1;
            }
            Session["Score"] = score; // Store the score in the session
            Response.Redirect("Result.aspx"); // Redirect to the result page
        }
    }
}


Result.aspx.cs

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

namespace WebApplication20
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) // Ensure this code runs only once when the page loads
            {
                if (Session["Score"] != null) // Check if the score exists in the session
                {
                    lblResult.Text = "Your Score: " + Session["Score"].ToString() + "/1"; // Display the score
                }
                else
                {
                    lblResult.Text = "No exam taken."; // Display a message if no exam was taken
                }
            }
        }
    }
}


8
Login.system.cs

using System; 
using System.Windows.Forms; 
 
namespace UserLoginApp 
    public partial class LoginSystem : Form 
    { 
        // Set predefined username and password 
        private string validUsername = "admin"; 
        private string validPassword = "1234"; 
 
        public LoginSystem() 
        { 
            InitializeComponent(); 
        } 
 
        private void btnLogin_Click(object sender, EventArgs e) 
        { 
            // Get user inputs 
            string username = txtUsername.Text; 
            string password = txtPassword.Text; 
 
            // Validate login credentials 
            if (username == validUsername && password == validPassword) 
            { 
                MessageBox.Show("Login Successful!", "Success", MessageBoxButtons.OK, 
MessageBoxIcon.Information); 
                // Open new form or main dashboard (if needed) 
                // MainForm mainForm = new MainForm(); 
                // mainForm.Show(); 
                // this.Hide(); 
            } 
            else 
            { 
                MessageBox.Show("Invalid Username or Password", "Login Failed", 
MessageBoxButtons.OK, MessageBoxIcon.Error); 
                txtUsername.Clear(); 
                txtPassword.Clear(); 
                txtUsername.Focus(); 
            } 
        } 
 
 
        private void btnExit_Click(object sender, EventArgs e)
{
    DialogResult result = MessageBox.Show("Do you want to exit?", "Exit Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    if (result == DialogResult.Yes)
    {
        Application.Exit();
    }
}

        private void label2_Click(object sender, EventArgs e)
        {

        }
    
    } 

LoginSystem.Designer.cs

namespace UserLoginApp
{
    partial class LoginSystem
    {
        private System.ComponentModel.IContainer components = null;
        private System.Windows.Forms.TextBox txtUsername;
        private System.Windows.Forms.TextBox txtPassword;
        private System.Windows.Forms.Button btnLogin;
        private System.Windows.Forms.Button btnExit;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.txtUsername = new System.Windows.Forms.TextBox();
            this.txtPassword = new System.Windows.Forms.TextBox();
            this.btnLogin = new System.Windows.Forms.Button();
            this.btnExit = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // txtUsername
            // 
            this.txtUsername.Location = new System.Drawing.Point(164, 50);
            this.txtUsername.Name = "txtUsername";
            this.txtUsername.Size = new System.Drawing.Size(86, 20);
            this.txtUsername.TabIndex = 0;
            // 
            // txtPassword
            // 
            this.txtPassword.Location = new System.Drawing.Point(164, 80);
            this.txtPassword.Name = "txtPassword";
            this.txtPassword.PasswordChar = '*';
            this.txtPassword.Size = new System.Drawing.Size(86, 20);
            this.txtPassword.TabIndex = 1;
            // 
            // btnLogin
            // 
            this.btnLogin.Location = new System.Drawing.Point(50, 120);
            this.btnLogin.Name = "btnLogin";
            this.btnLogin.Size = new System.Drawing.Size(75, 23);
            this.btnLogin.TabIndex = 2;
            this.btnLogin.Text = "Login";
            this.btnLogin.UseVisualStyleBackColor = true;
            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
            // 
            // btnExit
            // 
            this.btnExit.Location = new System.Drawing.Point(175, 120);
            this.btnExit.Name = "btnExit";
            this.btnExit.Size = new System.Drawing.Size(75, 23);
            this.btnExit.TabIndex = 3;
            this.btnExit.Text = "Exit";
            this.btnExit.UseVisualStyleBackColor = true;
            this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(64, 50);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(55, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Username";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(64, 87);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(53, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Password";
            this.label2.Click += new System.EventHandler(this.label2_Click);
            // 
            // LoginSystem
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(300, 200);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnExit);
            this.Controls.Add(this.btnLogin);
            this.Controls.Add(this.txtPassword);
            this.Controls.Add(this.txtUsername);
            this.Name = "LoginSystem";
            this.Text = "Login System";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
    }
}namespace UserLoginApp
{
    partial class LoginSystem
    {
        private System.ComponentModel.IContainer components = null;
        private System.Windows.Forms.TextBox txtUsername;
        private System.Windows.Forms.TextBox txtPassword;
        private System.Windows.Forms.Button btnLogin;
        private System.Windows.Forms.Button btnExit;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.txtUsername = new System.Windows.Forms.TextBox();
            this.txtPassword = new System.Windows.Forms.TextBox();
            this.btnLogin = new System.Windows.Forms.Button();
            this.btnExit = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // txtUsername
            // 
            this.txtUsername.Location = new System.Drawing.Point(164, 50);
            this.txtUsername.Name = "txtUsername";
            this.txtUsername.Size = new System.Drawing.Size(86, 20);
            this.txtUsername.TabIndex = 0;
            // 
            // txtPassword
            // 
            this.txtPassword.Location = new System.Drawing.Point(164, 80);
            this.txtPassword.Name = "txtPassword";
            this.txtPassword.PasswordChar = '*';
            this.txtPassword.Size = new System.Drawing.Size(86, 20);
            this.txtPassword.TabIndex = 1;
            // 
            // btnLogin
            // 
            this.btnLogin.Location = new System.Drawing.Point(50, 120);
            this.btnLogin.Name = "btnLogin";
            this.btnLogin.Size = new System.Drawing.Size(75, 23);
            this.btnLogin.TabIndex = 2;
            this.btnLogin.Text = "Login";
            this.btnLogin.UseVisualStyleBackColor = true;
            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
            // 
            // btnExit
            // 
            this.btnExit.Location = new System.Drawing.Point(175, 120);
            this.btnExit.Name = "btnExit";
            this.btnExit.Size = new System.Drawing.Size(75, 23);
            this.btnExit.TabIndex = 3;
            this.btnExit.Text = "Exit";
            this.btnExit.UseVisualStyleBackColor = true;
            this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(64, 50);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(55, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Username";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(64, 87);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(53, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Password";
            this.label2.Click += new System.EventHandler(this.label2_Click);
            // 
            // LoginSystem
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(300, 200);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnExit);
            this.Controls.Add(this.btnLogin);
            this.Controls.Add(this.txtPassword);
            this.Controls.Add(this.txtUsername);
            this.Name = "LoginSystem";
            this.Text = "Login System";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UserLoginApp
{
    static class Program
    {
        /// <summary> 
        /// The main entry point for the application. 
        /// </summary> 
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginSystem());
        }
    }
}

Site1.master

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

<!DOCTYPE html> 
 
<html> 
<head> 
    <title>College Website</title> 
    <link rel="stylesheet" type="text/css" href="Styles.css" /> 
</head> 
<body> 
    <form id="Form1" runat="server"> 
        <div class="header"> 
            <h1>Welcome to Our College</h1> 
            <nav> 
                <a href="Default.aspx">Home</a> | 
                <a href="About.aspx">About</a> | 
                <a href="Contact.aspx">Contact</a> 
            </nav> 
        </div> 
        <asp:ContentPlaceHolder ID="MainContent" 
runat="server"></asp:ContentPlaceHolder> 
        <div class="footer">&copy; 2025 College Name</div> 
    </form> 
</body> 
</html> 

Default.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 

    <h2>Welcome to Our College</h2> 

    <p>We provide quality education to students in various disciplines.</p>

   </asp:Content>


About.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" 
CodeBehind="About.aspx.cs" Inherits="WebApplication3.WebForm2" %> 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
     <h2>About Our College</h2> 
    <p>We are a premier institution offering world-class education.</p> 
</asp:Content>

Contact.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" 
CodeBehind="Contact.aspx.cs" Inherits="WebApplication3.WebForm3" %> 
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> 
    <h2>Contact Us</h2> 
    <p>Email: info@college.com</p> 
    <p>Phone: +91-9876543210</p> 
</asp:Content> 

  Styles.css 
 body 
{font-family: Arial, sans-serif; margin: 0; padding: 0; text-align: center; }
 .header { background: #004080; color: white; padding: 15px; }
 .footer { background: #222; color: white; padding: 10px; position: absolute; bottom: 0; width: 100%; } 
 nav a { color: white; text-decoration: none; margin: 0 10px; } 

Comments

Popular posts from this blog

RDBMS

.Net

1-5