





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















RegistrationForm.aspx:- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RegistrationForm.Default" %>
Registration Form
width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; } button { width: 100%; padding: 10px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background-color: #0056b3; } .error-message { color: red; font-size: 12px; margin-top: 3px; } .success-message { color: green; text-align: center; margin: 10px 0 ; }
User Registration Form
Username:
Mobile No:
RegistrationForm.aspx.cs:- using System; using System.Web.UI; using System.Web.UI.WebControls; namespace RegistrationForm { public partial class Default : Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) {
// Display success message lblMessage.Text = "Registration successful! Welcome " + txtUsername.Text; // Clear all fields ClearForm(); } } private void ClearForm() { txtUsername.Text = ""; txtPassword.Text = ""; txtConfirmPassword.Text = ""; txtAge.Text = ""; txtEmail.Text = ""; txtMobileNo.Text = ""; } // Custom validator for Mobile No protected void ValidateMobileNo(object sender, ServerValidateEventArgs e) { string mobileNo = e.Value; // Check if mobile number is exactly 10 digits if (mobileNo.Length == 10 && System.Text.RegularExpressions.Regex.IsMatch(mobileNo, @"^\d{10}$")) { e.IsValid = true; } else { e.IsValid = false; } } } } Output:-
input[type="text"]:focus { outline: none; border-color: #667eea; } .button-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; } button { padding: 12px; font-size: 16px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: all 0.3s ease; } .op-btn { background-color: #667eea; color: white; } .op-btn:hover { background-color: #5568d3; transform: translateY(-2px); } .clear-btn { grid-column: 1 / - 1 ; background-color: #ff6b6b; color: white; } .clear-btn:hover { background-color: #ee5a52; } .result-box { background-color: #f0f0f0; padding: 15px; border-radius: 4px; text-align: center; margin-top: 20px; } .result { font-size: 20px; color: #667eea; font-weight: bold; }
Calculator
First Number:
Second Number:
Result:
CalculatorProgram.aspx.cs:- using System; using System.Web.UI; namespace Calculator {
lblError.Text = "Cannot divide by zero"; return; } result = num1 / num2; break; } lblResult.Text = result.ToString(); } catch (FormatException) { lblError.Text = "Please enter valid numbers"; } catch (Exception ex) { lblError.Text = "Error: " + ex.Message; } } protected void btnClear_Click(object sender, EventArgs e) { txtNum1.Text = ""; txtNum2.Text = ""; lblResult.Text = "0"; lblError.Text = ""; } } } Output:-
StudentResult.aspx:- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudentResult.aspx.cs" Inherits="StudentManagement.StudentResult" %>
Student Result
justify-content: space-between; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(0,0,0,0.1); } .result-item:last-child { border-bottom: none; margin-bottom: 0 ; } .result-label { font-weight: bold; color: #2c3e50; } .result-value { color: #27ae60; font-weight: bold; } .error-message { color: #e74c3c; text-align: center; padding: 10px; background-color: #fadbd8; border-radius: 4px; margin-bottom: 10px; display: none; } .error-message.show { display: block; } .grade-badge { display: inline-block; padding: 5px 15px; background-color: #3498db; color: white; border-radius: 20px; font-weight: bold; }
Student Result Sheet
Student Name:
Subject 1 Marks (out of 100):
Subject 2 Marks (out of 100):
Subject 3 Marks (out of 100):
Subject 4 Marks (out of 100):
Subject 5 Marks (out of 100):
Student Name:
Total Marks:
if (string.IsNullOrWhiteSpace(txtSubject1.Text) || string.IsNullOrWhiteSpace(txtSubject2.Text) || string.IsNullOrWhiteSpace(txtSubject3.Text) || string.IsNullOrWhiteSpace(txtSubject4.Text) || string.IsNullOrWhiteSpace(txtSubject5.Text)) { lblError.Text = "Please enter marks for all subjects"; lblError.Attributes["class"] = "error-message show"; return; } // Parse marks int subject1 = int.Parse(txtSubject1.Text); int subject2 = int.Parse(txtSubject2.Text); int subject3 = int.Parse(txtSubject3.Text); int subject4 = int.Parse(txtSubject4.Text); int subject5 = int.Parse(txtSubject5.Text); // Validate range if (subject1 < 0 || subject1 > 100 || subject2 < 0 || subject2 > 100 || subject3 < 0 || subject3 > 100 || subject4 < 0 || subject4 > 100 || subject5 < 0 || subject5 > 100) { lblError.Text = "Marks must be between 0 and 100"; lblError.Attributes["class"] = "error-message show"; return; } // Calculate total and percentage int totalMarks = subject1 + subject2 + subject3 + subject4 + subject5; decimal percentage = (decimal)totalMarks / 5; // Determine grade string grade = GetGrade(percentage); // Display results lblResultName.Text = txtStudentName.Text; lblTotalMarks.Text = totalMarks.ToString(); lblPercentage.Text = percentage.ToString("F2"); lblGrade.Text = grade; lblStatus.Text = percentage >= 40? "PASS" : "FAIL"; // Show result section resultSection.Attributes["class"] = "result-section show"; } catch (FormatException) { lblError.Text = "Please enter valid numbers for marks"; lblError.Attributes["class"] = "error-message show"; } catch (Exception ex) { lblError.Text = "Error: " + ex.Message;
lblError.Attributes["class"] = "error-message show"; } } private string GetGrade(decimal percentage) { if (percentage >= 90) return "A+"; else if (percentage >= 80) return "A"; else if (percentage >= 70) return "B"; else if (percentage >= 60) return "C"; else if (percentage >= 50) return "D"; else return "F"; } protected void btnReset_Click(object sender, EventArgs e) { txtStudentName.Text = ""; txtSubject1.Text = ""; txtSubject2.Text = ""; txtSubject3.Text = ""; txtSubject4.Text = ""; txtSubject5.Text = ""; lblError.Attributes["class"] = "error-message"; resultSection.Attributes["class"] = "result-section"; } } } Output:-
border-radius: 6px; box-sizing: border-box; font-size: 15px; transition: border-color 0.3s ease; } input[type="date"]:focus { outline: none; border-color: #667eea; box-shadow: 0 0 8px rgba(102, 126, 234, 0.3); } .button-group { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 25px; } button { padding: 12px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 15px; transition: all 0.3s ease; } .btn-primary { background-color: #667eea; color: white; } .btn-primary:hover { background-color: #5568d3; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); } .btn-secondary { background-color: #f0f0f0; color: #333; } .btn-secondary:hover { background-color: #e0e0e0; } .result-box { background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); padding: 25px; border-radius: 8px; margin-top: 30px; text-align: center; display: none; border-left: 5px solid #667eea; }
.result-box.show { display: block; } .result-label { color: #666; font-size: 14px; margin-bottom: 10px; } .result-day { font-size: 32px; font-weight: bold; color: #667eea; margin: 10px 0 ; } .result-date { font-size: 16px; color: #555; margin-top: 10px; } .error-message { background-color: #fadbd8; color: #c0392b; padding: 12px; border-radius: 6px; margin-bottom: 15px; display: none; border-left: 4px solid #c0392b; } .error-message.show { display: block; } .today-btn { margin-top: 15px; } .today-btn button { width: 100%; background-color: #27ae60; color: white; padding: 10px; } .today-btn button:hover { background-color: #229954; }
📅 Day of Week Finder