NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

.cs
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;

namespace Practice02
{
public partial class FrontDesign : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=WORKSTATION-149;Initial Catalog=Login;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
getData();
}
}

public void getData()
{
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from User_Registration", con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();

}
catch
{

}
finally
{
con.Close();
}
}

protected void Button1_Click(object sender, EventArgs e)
{

try
{

if (txtName.Text == "")
{
throw new Exception("Please Enter Name");
}
if (txtFatherName.Text == "")
{
throw new Exception("Please Enter Father Name");
}
if (txtMotherName.Text == "")
{
throw new Exception("Please Enter Mother Name");
}

if (Dob2.Text == "")
{
throw new Exception("Please Enter Date Of Birth");
}

//[Required(ErrorMessage = "Gender is required.")]

//GENDER
//CATEGORY

if (txtNumber.Text == "")
{
throw new Exception("Please Enter Valid Number");
}

if(txtemail.Text == "")
{
throw new Exception("Please Enter Your Mail");
}

if (txtaddress.Text == "")
{
throw new Exception("Please Enter Your Address");
}

SqlCommand cmd = new SqlCommand("InsertData", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@Student_Name", txtName.Text.ToString());
cmd.Parameters.AddWithValue("@Father_Name ", txtFatherName.Text.ToString());
cmd.Parameters.AddWithValue("@Mother_Name ", txtMotherName.Text.ToString());
cmd.Parameters.AddWithValue("@Dob", Dob2.Text.ToString());
cmd.Parameters.AddWithValue("@Gender", RadioButtonList1.Text.ToString());
cmd.Parameters.AddWithValue("@Category", RadioButtonList2.Text.ToString());
cmd.Parameters.AddWithValue("@Email", txtemail.Text.ToString());
cmd.Parameters.AddWithValue("@Address", txtaddress.Text.ToString());
cmd.ExecuteNonQuery();
getData();
cmd.ExecuteNonQuery();

}

catch (Exception ex)
{
lblname1.Text = ex.Message;
lblname1.Visible = true;

}
finally
{
con.Close();
}

//Session["StudentName"] = "Anunaya";
Session["StudentName"] = txtName.Text;
Session["FatherName"] = txtFatherName.Text;
Session["MotherName"] = txtMotherName.Text;
Session["Dob"] = Dob2.Text;
Session["Gender"] = RadioButtonList1.Text;
Session["Category"] = RadioButtonList2.Text;
Session["Phone"] = txtNumber.Text;
Session["Email"] = txtemail.Text;
Session["Address"] = txtaddress.Text;
Response.Redirect("ShowReceipt.aspx");
}

protected void datagridview_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
getData();
}

protected void datagridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int rowno = Int32.Parse(e.CommandArgument.ToString());
try
{
con.Open();
string Phone_No = GridView1.Rows[rowno].Cells[6].Text.ToString();
SqlCommand cmd = new SqlCommand("DeleteData", con);
cmd = new SqlCommand("Delete from User_Registration where Phone_No ='" + Phone_No + "'", con);
cmd.ExecuteNonQuery();
lblname1.Text = "Deleted Successfully.";
getData();

}
catch (Exception ex)
{
lblname1.Text = ex.Message.ToString();

}
finally
{
con.Close();
}
}

}

//protected void Update_Rows(object sender, GridViewCommandEventArgs e)
//{
// if (e.CommandName == "Update")
// {
// int rowno = Int32.Parse(e.CommandArgument.ToString());
// try
// {
// con.Open();
// string Update = GridView1.Rows[rowno].Cells[6].Text.ToString();
// SqlCommand cmd = new SqlCommand("SelectData", con);
// cmd = new SqlCommand("Update from User_Registration where Phone_No ='" + Update + "'", con);
// cmd.ExecuteNonQuery();
// lblname2.Text = "Update Successfully.";
// getData();

// }
// catch (Exception ex)
// {
// lblname2.Text = ex.Message.ToString();

// }
// finally
// {
// con.Close();
// }
// }

protected void datagridview_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
}


aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrontDesign.aspx.cs" Inherits="Practice02.FrontDesign" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Model | Design</title>
<link rel="StyleSheet" href="FrontStyleSheet.css" />
<%--<script src="Validation.js" type="text/javascript"></script>--%>

<script>

function setFocus() {
document.getElementById("txtName").focus();
}
function outFocus1() {
var Student_Name = document.getElementById("txtName");
if (Student_Name.value == "") {
document.getElementById("txtName").style.borderColor = "red";
}
else {
document.getElementById("txtName").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("txtMotherName").focus();
}
function outFocus2() {
var Mother_Name = document.getElementById("txtMotherName");
if (Mother_Name.value == "") {
document.getElementById("txtMotherName").style.borderColor = "red";
}
else {
document.getElementById("txtMotherName").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("txtFatherName").focus();
}
function outFocus3() {
var Father_Name = document.getElementById("txtFatherName");
if (Father_Name.value == "") {
document.getElementById("txtFatherName").style.borderColor = "red";
}
else {
document.getElementById("txtFatherName").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("Dob2").focus();
}
function outFocus4() {
var DOB = document.getElementById("Dob2");
if (DOB.value == "") {
document.getElementById("Dob2").style.borderColor = "red";
}
else {
document.getElementById("Dob2").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("RadioButtonList1").focus();
}
function outFocus5() {
var Gender = document.getElementById("RadioButtonList1");
if (Gender.value == "") {
document.getElementById("RadioButtonList1").style.borderColor = "red";
}
else {
document.getElementById("RadioButtonList1").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("RadioButtonList2").focus();
}
function outFocus6() {
var Category = document.getElementById("RadioButtonList2");
if (Category.value == "") {
document.getElementById("RadioButtonList2").style.borderColor = "red";
}
else {
document.getElementById("RadioButtonList2").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("txtNumber").focus();
}
function outFocus7() {
var Phone_Number = document.getElementById("txtNumber");
if (Phone_Number.value == "") {
document.getElementById("txtNumber").style.borderColor = "red";
}
else {
document.getElementById("txtNumber").style.borderColor = "";
}
}

function setFocus() {
document.getElementById("txtemail").focus();
}
function outFocus8() {
var Email = document.getElementById("txtemail");
if (Email.value == "") {
document.getElementById("txtemail").style.borderColor = "red";
}
else {
document.getElementById("txtemail").style.borderColor = "";
}
}

function setFocus9() {
document.getElementById("txtaddress").focus();
}
function outFocus9() {
var Address = document.getElementById("txtaddress");
if (Address.value == "") {
document.getElementById("txtaddress").style.borderColor = "red";
}
else {
document.getElementById("txtaddress").style.borderColor = "";
}
}

//FUNCTION RESET FORM
function reset()
{
document.getElementById("Form1").reset();
}

function validate() {

var Student_Name = document.getElementById("txtName");
var Mother_Name = document.getElementById("txtMotherName");
var Father_Name = document.getElementById("txtFatherName");
var DOB = document.getElementById('Dob2').value;
var Gender = document.getElementById('RadioButtonList1').value;
var Category = document.getElementById('RadioButtonList2').value;
var Phone_Number = document.getElementById("txtNumber");
var Email = document.getElementById("txtemail");
var Address = document.getElementById("txtaddress");

if (txtName.value == "") {
alert("Please Enter Student Name");
return false;
}
var letter1 = /^[A-Z a-z]+$/;
if (!txtName.value.match(letter1)) {
alert("Please Enter Characters Only");
return false;
}

if (txtMotherName.value == "") {
alert("Please Enter Mother Name");
return false;
}
var letter1 = /^[A-Z a-z]+$/;
if (!txtMotherName.value.match(letter1)) {
//alert("Please Enter Characters Only");
return false;
}

if (txtFatherName.value == "") {

alert("Please Enter Father Name");
return false;
}

var letter1 = /^[A-Z a-z]+$/;
if (txtFatherName.value.match(letter1)) {
//alert("Please Enter Characters Only");
return false;
}

if (Dob2.value == '') {
alert("Please enter Your Date Of Birth.");
return false;
}

var a = 0, RadioButtonList1 = document.getElementsByName("RadioButtonList1")
for (i = 0; i < RadioButtonList1.length; i++) {
if (RadioButtonList1.item(i).checked == false) {
a++;
}
}
if (a == RadioButtonList1.length) {
alert("Please select your Gender");
document.getElementById("RadioButtonList1");
return false;
}
var a = 0, RadioButtonList2 = document.getElementsByName("RadioButtonList2")
for (i = 0; i < RadioButtonList2.length; i++) {
if (RadioButtonList2.item(i).checked == false) {
a++;
}
}
if (a == RadioButtonList2.length) {
alert("Please select your Category");
document.getElementById("RadioButtonList2");
return false;
}

if (txtNumber.value == "") {
alert("Please Enter Phone Number");
return false;
}
var letter1 = /^[0-9]+$/;
if (!txtNumber.value.match(letter1)) {
alter("Please Enter Digits Only");
return false;
}

if (txtemail.value == "") {
alert("Please Enter Your Email ID");
return false;
}
var mailformat = /S+@S+.S+/;
if (!txtemail.value.match(mailformat)) {
alert("Please Enter VAlID Email");
}

if (txtaddress.value == "") {
alert("Please Enter Your Address Details Below");
return false;
}
return true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h2> User Registration </h2>

<table border="1">
<tr>
<td class="auto-style1">
<asp:Label ID="lblName" Text="Student Name :" runat="server"></asp:Label>
<asp:TextBox ID="txtName" runat="server" onfocusout="outFocus1()"></asp:TextBox><br/><br />

<asp:Label ID="lblFatherName" Text="Father Name :" runat="server" ></asp:Label>
<asp:TextBox ID="txtFatherName" runat="server" onfocusout="outFocus2()"></asp:TextBox><br /><br />
</td>

<td>
<asp:Label ID="lblMotherName" Text="Mother Name :" runat="server"></asp:Label>
<asp:TextBox ID="txtMotherName" runat="server" onfocusout="outFocus3()"></asp:TextBox><br /><br />

<asp:Label ID="lablDOB" Text="Date of Birth :" runat="server" ></asp:Label>
<asp:TextBox ID="Dob2" runat="server" TextMode="Date" onfocusout="outFocus4()"></asp:TextBox><br/><br/>

</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lblGender" Text="Gender :" runat="server"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" onfocusout="outFocus5()">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
<%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Please select a Gender.<br />"
ControlToValidate="Gender" runat="server" Display="Dynamic" />--%>
</td>

<td>
<asp:Label ID="lblCategory" Text="Category :" runat="server"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList2" runat="server" onfocusout="outFocus6()">
<asp:ListItem>General</asp:ListItem>
<asp:ListItem>Obc</asp:ListItem>
<asp:ListItem>SC</asp:ListItem>
<asp:ListItem>ST</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lblNumber" Text="Phone No. :" runat="server"></asp:Label>
<asp:TextBox ID="txtNumber" runat="server" onfocusout="outFocus7()"></asp:TextBox><br /><br/>
</td>

<td>
<asp:Label ID="lblemail" Text="E-mail :" runat="server"></asp:Label>
<asp:TextBox ID="txtemail" runat="server" onfocusout="outFocus8()"></asp:TextBox><br/><br/>

</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="lbladdress" Text="Address :" runat="server"></asp:Label>
<asp:TextBox ID="txtaddress" runat="server" Width="202px" onfocusout="outFocus9()"></asp:TextBox><br/><br/>
</td>
</tr>

<tr class="tr1">
<td class="auto-style1">
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" OnClientClick="setFocus()" style="height: 26px" />
<%-- validate()"--%>
<asp:Button ID="Button2" runat="server" Text="Reset" onClientClick="return reset()"/>
</td>
<asp:Label runat="server" Text=" " ID="lblname1"
ForeColor="#507CD1" Font-Size="20px"></asp:Label>
<asp:Label runat="server" Text=" " ID="lblname2"
ForeColor="#507CD1" Font-Size="20px"></asp:Label>
</tr>
</table>
<br /><br />

<table border="1">
<tr>
<td colspan="2">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
OnPageIndexChanging="datagridview_PageIndexChanging" OnRowCommand="datagridview_RowCommand" OnRowDeleting="datagridview_RowDeleting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Height="199px">
<Columns>
<asp:BoundField DataField="Student_Name" HeaderText="Student Name" />
<asp:BoundField DataField="Father_Name" HeaderText="Father Name" />
<asp:BoundField DataField="Mother_Name" HeaderText="Mother Name" />
<asp:BoundField DataField="Dob" HeaderText="Date of Birth" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:BoundField DataField="Category" HeaderText="Category" />
<asp:BoundField DataField="Phone_No" HeaderText="Phone_No" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:BoundField DataField="Address" HeaderText="Address" />

<asp:ButtonField ButtonType="Button" HeaderText="Delete Data" Text="Delete" CommandName="Delete" />
<asp:ButtonField ButtonType="Button" HeaderText="Update Data" Text="Update" CommandName="Update" />

</Columns>

</asp:GridView>
</td>
</tr>

</table>

</form>
</body>
</html>


receipt aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowReceipt.aspx.cs" Inherits="Practice02.ShowReceipt" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RECEIPT PAGE</title>
<style>
.a{
background-color:lavender;
}
.auto-style1 {
width: 250px;
height: 20px;
}
.auto-style2 {
width: 300px;
height: 20px;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<h2>Registration Receipt </h2>
<table border="2" class="a">
<tr>
<td class="auto-style1" >
<asp:Label ID="Name" Text="Student Name" runat="server" ></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblStudentName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="FatherName" Text="Father Name" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblFatherName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="MotherName" Text="Mother Name" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblMotherName" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="DOB" Text="Date of Birth" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblDOB" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="Gender" Text="Gender" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblGender" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="Category" Text="Category" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblCategory" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="PhoneNo" Text="Phone Number" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblPhoneNo" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="Email" Text="Email" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblEmail" runat="server"></asp:Label>
</td>
</tr>

<tr>
<td class="auto-style1">
<asp:Label ID="Address" Text="Address" runat="server"></asp:Label>
</td>
<td class="auto-style2">
<asp:Label ID="lblAddress" runat="server"></asp:Label>
</td>
</tr>

</table>
</form>
</body>
</html>


receipt.cs

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;
namespace Practice02
{
public partial class ShowReceipt : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=WORKSTATION-149;Initial Catalog=Login;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
//Read values from session
if (!String.IsNullOrEmpty(Session["StudentName"].ToString()))
{

string StudentName = Session["StudentName"].ToString();
lblStudentName.Text = StudentName;
//getData();
}
if (!String.IsNullOrEmpty(Session["FatherName"].ToString()))
{

string FatherName2 = Session["FatherName"].ToString();
lblFatherName.Text = FatherName2;
}
if (!String.IsNullOrEmpty(Session["MotherName"].ToString()))
{

string MotherName3 = Session["MotherName"].ToString();
lblMotherName.Text = MotherName3;
}
if (!String.IsNullOrEmpty(Session["Dob"].ToString()))
{

string Dob4 = Session["Dob"].ToString();
lblDOB.Text = Dob4;
}
if (!String.IsNullOrEmpty(Session["Gender"].ToString()))
{

string Gender = Session["Gender"].ToString();
lblGender.Text = Gender;
}
if (!String.IsNullOrEmpty(Session["Category"].ToString()))
{

string Category = Session["Category"].ToString();
lblCategory.Text = Category;
}
if (!String.IsNullOrEmpty(Session["Phone"].ToString()))
{

string Phone = Session["Phone"].ToString();
lblPhoneNo.Text = Phone;
}
if (!String.IsNullOrEmpty(Session["Email"].ToString()))
{

string Email = Session["Email"].ToString();
lblEmail.Text = Email;
}
if (!String.IsNullOrEmpty(Session["Address"].ToString()))
{

string Address = Session["Address"].ToString();
lblAddress.Text = Address;
}

}

public void getData()
{
try
{
//string StudentName = Session["StudentName"].ToString();

//string StudentName = "Anunaya";
//string abc = "select * from User_Registration where Student_Name='" + StudentName + "'";

string abc = "select * from User_Registration";
con.Open();
SqlDataAdapter da = new SqlDataAdapter(abc, con);
SqlCommand cmd = new SqlCommand("InsertData", con);
cmd.CommandType = CommandType.StoredProcedure;
DataTable dt = new DataTable();
da.Fill(dt);

if (dt != null || dt.Rows.Count > 0)
{
lblStudentName.Text = dt.Rows[0]["Student_Name"].ToString();
lblFatherName.Text = dt.Rows[0]["Father_Name"].ToString();
lblMotherName.Text = dt.Rows[0]["Mother_Name"].ToString();
lblDOB.Text = dt.Rows[0]["Dob"].ToString();
lblGender.Text = dt.Rows[0]["Gender"].ToString();
lblCategory.Text = dt.Rows[0]["Category"].ToString();
lblPhoneNo.Text = dt.Rows[0]["Phone_No"].ToString();
lblEmail.Text = dt.Rows[0]["Email"].ToString();
lblAddress.Text = dt.Rows[0]["Address"].ToString();
}

}
catch
{

}
finally
{
con.Close();
}
}
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.