MiniProject


How Create Login ,LogOut form manually in asp.net ?

Here’s what you want to do:
Step: - 1) Create Login Page include two text box & a button.
Step: - 2) Create a Folder(give name Computer) in side folder , create a master page(Computer.Master).
Step: - 3) Create a LogOUT Page (with out applying master page ) simple form.
Step: - 4) SaveàBuildàRun.

Step1)


In aspx
<table class="style1">
    <tr>
        <td class="style2">
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style14">
          <h1>&nbsp;</h1></td>
    </tr>
    <tr>
        <td class="style3">
            <table class="style5">
                <tr>
                    <td class="style6">
                        &nbsp;</td>
                    <td class="style7">
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style8">
                        User ID*</td>
                    <td class="style7">
                        <asp:TextBox ID="TextBox1" runat="server" Width="266px"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style6">
                        &nbsp;</td>
                    <td class="style9">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                            ControlToValidate="TextBox1" ErrorMessage="Enter User ID" ValidationGroup="ld"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style8">
                        Password*</td>
                    <td class="style7">
                        <asp:TextBox ID="TextBox2" runat="server" TextMode="Password" Width="211px"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style8">
                        &nbsp;</td>
                    <td class="style9">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                            ControlToValidate="TextBox2" ErrorMessage="Enter Password" ValidationGroup="ld"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style8">
                        &nbs&nbsp;</td>
                    <td class="style7">
                        <asp:Button ID="Button1" runat="server" Text="Submit" ValidationGroup="ld" onclick="Button1_Click"
                             />
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="style11">
            <span
                class="style12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span> </td>
    </tr>
    <tr>
        <td class="style11">
            &nbsp;</td>
    </tr>
    </table>&nbsp;</p>
C# code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
namespace TestDemo
{
    public partial class _Default : System.Web.UI.Page
    {

        string cn = (string)ConfigurationSettings.AppSettings["con"];
          
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
   
   
     protected void Button1_Click(object sender, EventArgs e)
     {
         try
         {
             string st = "Approved";
             SqlConnection con = new SqlConnection(cn);
             con.Open();
             SqlCommand cmd = new SqlCommand("select Password,LoginID,rollno from tbl_WSS_UBE_Placement_Student where LoginID='" + TextBox1.Text.Replace("'", "") + "' and Password='" + TextBox2.Text.Replace("'", "") + "'and Status='" + st.ToString() + "'", con);
             SqlDataReader dr = cmd.ExecuteReader();
             if (dr.Read())
             {
                 Session["sname"] = TextBox1.Text;
                 Session["spass"] = TextBox2.Text;
                 //Session["rollno"] = dr[2].ToString();
                 //Session["admin1"] = 1;

                 Response.Redirect("Computer//HomeCSE.aspx");
             }
             else
             {
              // Literal1.text=”Invalid UserName or Password!!”
                 TextBox1.BorderColor = System.Drawing.Color.Red;
                 TextBox2.BorderColor = System.Drawing.Color.Red;
                 TextBox1.Text = "";
             }
         }
         catch
         { }   
     }
        
        }
}

Step2)

ComputerSit.Master
In aspx
<div>
         Welcome&nbsp;&nbsp;
                <asp:Literal ID="Literal1" runat="server"></asp:Literal>
                | Help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                 <a class="style5" href="../Logout.aspx"><span class="style6">Signout</span></a>

        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
       
        </asp:ContentPlaceHolder>
    </div>

ComputerSit.Master.cs(c# code)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TestDemo.Computer
{
    public partial class ComputerSit : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["sname"] == null)
            {
                Response.Redirect("../Default.aspx?p=1");
            }
            else
            {
                Literal1.Text = Session["sname"].ToString();
            }
        }
    }
}

Step3)

Create logout page
Logout.aspx(without master page applying)
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TestDemo
{
    public partial class Logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("Default.aspx");
        }
    }
}
HomeCSE.aspx

C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

namespace TestDemo.Computer
{
    public partial class HomeCSE : System.Web.UI.Page
    {

        string con1 = (string)ConfigurationSettings.AppSettings["con"];
        string bid, sid, did, subid;
        string unc;

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

            }
        }

        public void Fill_Branch()
        {
            string s = (string)(Session["spass"]);
            string sn = (string)(Session["sname"]);
            try
            {
                SqlConnection cn = new SqlConnection(con1);
                cn.Open();
                //SqlCommand cmd = new SqlCommand("select distinct Branch_Name from tbl_WSS_UBE_Degree_Branch order by Branch_Name", cn);
                SqlCommand cmd = new SqlCommand("select  StudentBranch from tbl_WSS_UBE_Placement_Student where LoginID='" + sn + "' and Password='" + s + "' ", cn);
                SqlDataReader dr = cmd.ExecuteReader();

                //while (dr.Read())
                //{
                //    DropDownList4.Items.Add(dr[0].ToString());
                //}
                if (dr.Read())
                {
                    string val = dr["StudentBranch"].ToString();
                    TextBox1.Text = val;
                    // DropDownList4.Items.Add(val);
                }
                cn.Close();
                cn.Dispose();
            }
            catch { }
        }
    }
}

Step: - 4) SaveàBuildàRun.






How to Insert, Edit, Delete using StoreProcedure  in GridView in Asp.Net ?

In this article, I will explain how to insert, update, and delete data using store procedure in grid view. Let start to

Step-1:- Design a table in DataBase & give name ClientRegistration with respective DataType as follow.


Step-2:- Create a store procedure in DataBase & give name AddClientRegistration as follow.

Create PROCEDURE dbo.AddClientRegistration
          (
           
          @fname nvarchar (50),
          @lname nvarchar(50),
          @mobile varchar(50),
          @address ntext
         
          )
AS
          /* SET NOCOUNT ON */
          Insert  INTO ClientRegistration ( fname,lname,mobile,address )
                                 VALUES( @fname,@lname,@mobile,@address)
RETURN

Step-3:- After that design aspx page & give name client.aspx.
We required 1)TextBox 2)Button 3) Grid View 4) Summary Validation as follow.


ClientReg.aspx
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
Width="404px" Font-Bold="True"
ForeColor="#CC3300" />
<fieldset class="register">
<legend>Client Registration</legend>
<p>

<table class="style2">
<tr>
<td class="style3">
&nbsp;</td>
<td>
<asp:Label ID="lblMessage" runat="server" ForeColor="#3333FF"></asp:Label>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
First Name:</td>
<td>
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvUser" ErrorMessage="Please enter Client Name"
ControlToValidate="txtFName" runat="server" ForeColor="#CC3300" >*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
Last Name:</td>
<td>
<asp:TextBox ID="txtLName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Please Enter Last Name"
ControlToValidate="txtFName" runat="server" ForeColor="#CC3300">*</asp:RequiredFieldValidator>

</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
Mobile Number:</td>
<td>
<asp:TextBox ID="txtMobile" runat="server" MaxLength="10">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ErrorMessage="Please Enter Mobile Number"ControlToValidate="txtMobile" runat="server" ForeColor="#CC3300">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
Address:</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ErrorMessage="Please Enter Address"
ControlToValidate="txtAddress" runat="server" ForeColor="#CC3300">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
&nbsp;</td>
<td>
&nbsp;</td>
<td>
<asp:Button ID="btnAddClient" runat="server" Text="Add Client"
onclick="btnAddClient_Click" />
</td>
</tr>
</table>
</p>
</fieldset>
<br />
<fieldset class="register">
<legend>View Client Registration</legend>
<p>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
DataKeyNames="cid" AutoGenerateEditButton="True"
AutoGenerateColumns="False" AllowPaging="True"
onpageindexchanging="GridView1_PageIndexChanging"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating" PageSize="2"  >
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="cid" HeaderText="User ID" ReadOnly="True" />
<asp:TemplateField HeaderText="First Name">
<ItemTemplate>
<%# Eval("fName")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtfName" runat="Server" Text='<%# Eval("fName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name">
<ItemTemplate>
<%# Eval("lName")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtlName" runat="Server" Text='<%# Eval("lName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mobile">
<ItemTemplate>
<%# Eval("Mobile")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtMobile" runat="Server" Text='<%# Eval("Mobile") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<%# Eval("Address")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtAddress" runat="Server" Text='<%# Eval("Address") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<span onclick="return confirm('Are you sure to Delete?')">
<asp:LinkButton ID="lnBD" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</p>
</fieldset>

Step-4:- After that design aspx page, I have one grid view I need to write code to insert, update, delete, so we required following event as follow.
1)PageIndexChanging.
2)RowCancelingEdit.
3)RowEditing.
4)RowUpdating.
5)RowDeleting.



Now
Step-5:- Write following code in client.aspx.cs as follow.
You have to add following namespace in code behind(.cs)
using System.Data.SqlClient;  //add this namespace
using System.Configuration;  //add this namespace
using System.Drawing;     //add this namespace
ClientReg.aspx .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;  //add this namespace
using System.Configuration;  //add this namespace
using System.Drawing;     //add this namespace
using System.Data;

public partial class Admin_ClientRegistration : System.Web.UI.Page
{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //for GridView Binding
            BindGridView();
        }
    }
    //for GridView Binding
    private void BindGridView()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from ClientRegistration", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();

    }
    protected void btnAddClient_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();

            SqlCommand cmd = new SqlCommand("AddClientRegistration", con);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;


            // SqlParameter cid = new SqlParameter("@cid", System.Data.SqlDbType.BigInt);
          SqlParameter fname = new SqlParameter("@fname", System.Data.SqlDbType.NVarChar, 50);
          SqlParameter lname = new SqlParameter("@lname", System.Data.SqlDbType.NVarChar, 50);
          SqlParameter mobile = new SqlParameter("@mobile", System.Data.SqlDbType.Char, 10);
          SqlParameter address = new SqlParameter("@address", System.Data.SqlDbType.NText);

            //cmd.Parameters.AddWithValue("@cid",);
            cmd.Parameters.AddWithValue("@fname", txtFName.Text);
            cmd.Parameters.AddWithValue("@lname", txtLName.Text);
            cmd.Parameters.AddWithValue("@mobile", txtMobile.Text);
            cmd.Parameters.AddWithValue("@address", txtAddress.Text);

            cmd.ExecuteNonQuery();

            lblMessage.Text = "Successfully Client Reg!!!!!!!!!!!";
           
            ClearAll();
            con.Close();
            con.Dispose();

            BindGridView();
        }
        catch
        {

        }
    }
    private void ClearAll()
    {
        txtFName.Text = string.Empty;
        txtLName.Text = string.Empty;
        txtMobile.Text = string.Empty;
        txtAddress.Text = string.Empty;

    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindGridView();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int cid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["cid"].ToString());

        //string username = GridView1.DataKeys[e.RowIndex].Values["UserName"].ToString();

        con.Open();
 SqlCommand cmd = new SqlCommand("delete from ClientRegistration where cid=" + cid, con);
        int result = cmd.ExecuteNonQuery();
        con.Close();
        if (result == 1)
        {
            // Rebind the GridView control to show data after deleting.
            BindGridView();
            lblMessage.ForeColor = Color.Red;
            lblMessage.Text = " details deleted successfully";

        }
    }
  protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BindGridView();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindGridView();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int cid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());

        //string username = GridView1.DataKeys[e.RowIndex].Values["UserName"].ToString();
        TextBox FirstName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtfName");
        TextBox LastName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtlName");
        TextBox MobileNo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtmobile");
        TextBox Addresss = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtaddress");

      
        con.Open();
 SqlCommand cmd = new SqlCommand("update ClientRegistration set
                fname='" + FirstName.Text + "',lname='" + LastName.Text + "',
                mobile='" + MobileNo.Text + "',address='" + Addresss.Text + "'
                where cid=" + cid, con);

        cmd.ExecuteNonQuery();

        con.Close();
        lblMessage.ForeColor = Color.Green;
        lblMessage.Text = " Details Updated successfully";
        GridView1.EditIndex = -1;

        BindGridView();

    }
}

Step-6:- Build-àSaveàRun.




Binding DropDownList With table?



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.Configuration;
using System.Data;
using System.IO;
using System.Drawing;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;

public partial class Admin_BillGeneration : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);

    int prices, result;
    Decimal total;
    string cvid;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridView();
            BindCName();
            BindVCName();
        }
    }
    private void BindGridView()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from BillGeneration", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    private void BindCName()
    {
        SqlCommand cmd = new SqlCommand("select fname from ClientRegistration", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlCName.DataSource = ds;
        ddlCName.DataTextField = "fname";
        ddlCName.DataValueField = "fname";
        ddlCName.DataBind();
        //ddlCName.Items.Insert(0, new ListItem("--Select Client Name--", "0"));
        ddlCName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select Client Name--"));
       
    }

    private void BindVCName()
    {
       SqlCommand cmd = new SqlCommand("select VehicleCategories from VehicleCategories", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
    
        ddlVehicle.DataSource = ds;
        ddlVehicle.DataTextField = "VehicleCategories";
        ddlVehicle.DataValueField = "VehicleCategories";
        ddlVehicle.DataBind();
        //ddlVehicle.Items.Insert(0, new ListItem("--Select Vehicle Categories Name--", "0"));
        ddlVehicle.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select Vehicle Categories Name--"));
      
    }

    protected void btnBillGen_Click(object sender, EventArgs e)
    {
        GetData();
    }
    public void GetData()
    {
        getALLVALUE();

        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
            
            con.Open();
            SqlCommand cmd = new SqlCommand("AddBillGeneration", con);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;


            //SqlParameter cid = new SqlParameter("@cid", System.Data.SqlDbType.BigInt);

            SqlParameter ClientName = new SqlParameter("@ClientName", System.Data.SqlDbType.NVarChar, 50);
            SqlParameter VehicleCategoriesName = new SqlParameter("@VehicleCategoriesName", System.Data.SqlDbType.NVarChar, 50);
            SqlParameter CostAsPerVCName = new SqlParameter("@CostAsPerVCName", System.Data.SqlDbType.Decimal);
            SqlParameter Date = new SqlParameter("@Date", System.Data.SqlDbType.Date);
            SqlParameter StartKilomete = new SqlParameter("@StartKilomete", System.Data.SqlDbType.BigInt);
            SqlParameter EndKilomete = new SqlParameter("@EndKilomete", System.Data.SqlDbType.BigInt);
            SqlParameter TotalKilomete = new SqlParameter("@TotalKilomete", System.Data.SqlDbType.BigInt);
            SqlParameter TotalAmount = new SqlParameter("@TotalAmount", System.Data.SqlDbType.Decimal);

            //cmd.Parameters.AddWithValue("@cid",);
            cmd.Parameters.AddWithValue("@ClientName", ddlCName.Text);
            cmd.Parameters.AddWithValue("@VehicleCategoriesName", ddlVehicle.Text);
            cmd.Parameters.AddWithValue("@CostAsPerVCName", txtCostAsPerVCName.Text);
            cmd.Parameters.AddWithValue("@Date"DateTime.Now);
            cmd.Parameters.AddWithValue("@StartKilomete"Convert.ToInt32(txtStartMiles.Text));
            cmd.Parameters.AddWithValue("@EndKilomete"Convert.ToInt32(txtEndMiles.Text));
            cmd.Parameters.AddWithValue("@TotalKilomete"Convert.ToInt32(TextBox1.Text));
            cmd.Parameters.AddWithValue("@TotalAmount"Convert.ToDecimal(TextBox2.Text));

            cmd.ExecuteNonQuery();
            lblMessage.Text = "Successfully!!!!!!!!!!!";
            BindGridView();
            //lblMessage.Visible = true;
            con.Close();
            con.Dispose();
            // ClearAll();
        }
        catch (Exception e)
        {

            lblMessage.Text = e.Message;
        }
    }
    public void getALLVALUE()
    {
        try
        {

            string val = ddlVehicle.Text;
          
            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT CostPerKilo FROM  VehicleCategories WHERE  (VehicleCategories ='" + val + "')", con);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                cvid = dr[0].ToString();
            }

            txtCostAsPerVCName.Text = cvid;
            //txtCostAsPerVCName.Text = cvid.ToString();

            Decimal rr = Decimal.Parse(txtCostAsPerVCName.Text);

            int n1 = int.Parse(txtStartMiles.Text);
            int n2 = int.Parse(txtEndMiles.Text);

            total = n2 - n1;
            //lblTotalMiles.Text = total.ToString() + "Kilomete";
            TextBox1.Text = total.ToString();
            //TextBox1.Text = total;
            lblMessage.Visible = false;


            //Decimal result = (total) * (Decimal.Parse(txtCostAsPerVCName.Text));
            Decimal result = (total) * rr;
            // lblTotalAmount.Text = result.ToString() + "RS";
            // InsertBill();
            TextBox2.Text = result.ToString();

            con.Close();
            con.Dispose();

        }
        catch (Exception ex1)
        {

            Response.Write(ex1.Message);
        }
    }
    private void ClearAll()
    {
        ddlCName.SelectedIndex = 0;
        ddlVehicle.SelectedIndex = 0;
        txtCostAsPerVCName.Text = string.Empty;
        txtStartMiles.Text = string.Empty;
        txtEndMiles.Text = string.Empty;
        TextBox1.Text = string.Empty;
        TextBox2.Text = string.Empty;


    }
    public override void VerifyRenderingInServerForm(Control control)
    {
        /* Verifies that the control is rendered */
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition""attachment;filename=UserDetails.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        GridView1.AllowPaging = false;
        GridView1.DataBind();
        GridView1.RenderControl(hw);
        GridView1.HeaderRow.Style.Add("width""15%");
        GridView1.HeaderRow.Style.Add("font-size""10px");
        GridView1.Style.Add("text-decoration""none");
        GridView1.Style.Add("font-family""Arial, Helvetica, sans-serif;");
        GridView1.Style.Add("font-size""8px");
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
        //pdfDoc.Close();
        if (pdfDoc.PageNumber == 0)
        {
            Response.Write("No PageNumber");

        } pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
      
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindGridView();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BindGridView();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindGridView();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int bgid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());

        //string username = GridView1.DataKeys[e.RowIndex].Values["UserName"].ToString();
        //TextBox txtClientNameo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtClientName");
       // TextBox txtVehicleCategoriesNameo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtVehicleCategoriesName");
        //TextBox txtCostAsPerVCNameo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCostAsPerVCName");
        TextBox txtDateo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDate");
        TextBox txtStartKilometeo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStartKilomete");
        TextBox txtEndKilometeo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtEndKilomete");
        //TextBox txtTotalKilometeo = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtTotalKilomete");
        //TextBox txtTotalAmounto = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtTotalAmount");


        con.Open();
        SqlCommand cmd = new SqlCommand("update BillGeneration set Date='" + txtDateo.Text + "',StartKilomete='" + txtStartKilometeo.Text + "',EndKilomet='" + txtEndKilometeo.Text + "'where bgid=" + bgid, con);
        cmd.ExecuteNonQuery();
        con.Close();
        //lblMessage.ForeColor = Color.Green;
        lblMessage.Text = " Details Updated successfully";
        GridView1.EditIndex = -1;
        BindGridView();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int bgid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["bgid"].ToString());
        //string username = GridView1.DataKeys[e.RowIndex].Values["UserName"].ToString();
        con.Open();
        SqlCommand cmd = new SqlCommand("delete from BillGeneration where bgid=" + bgid, con);
        int result = cmd.ExecuteNonQuery();
        con.Close();
        if (result == 1)
        {
            // Rebind the GridView control to show data after deleting.
            BindGridView();
            //lblMessage.ForeColor = Color.Red;
            lblMessage.Text = " details deleted successfully";

        }
    }
}





How create Registation from and automatically send mail to student

Aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Computer.Master" AutoEventWireup="true" CodeBehind="CSEStudentRegistration.aspx.cs" Inherits="HMSITFinal.CSEStudentRegistration" %>



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



<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<table class="style1">
        <tr>
            <td class="style9">
                <asp:Literal ID="Literal1" runat="server"></asp:Literal>
            </td>
        </tr>
        <tr>
            <td class="style7">
                <h1> Registration Area</h1></td>
        </tr>
        <tr>
            <td>
                <table class="style1">
                    <tr>
                        <td class="style6">
                            Roll Number*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox1" runat="server" Width="286px" MaxLength="10"
                                ToolTip="Accepts Only 10 Alphanumeric"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                            ControlToValidate="TextBox1" ErrorMessage="Enter Roll Number"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Student Name*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox2" runat="server" Width="286px" MaxLength="50"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                            ControlToValidate="TextBox2" ErrorMessage="Enter Name" ValidationGroup="ld"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Branch*</td>
                        <td class="style8">
                            <asp:DropDownList ID="DropDownList1" runat="server" Width="288px">
                                <asp:ListItem>Select Branch..</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                            ControlToValidate="DropDownList1" ErrorMessage="Select Branch"
                                ValidationGroup="ld" InitialValue="Select Branch.."></asp:RequiredFieldValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Year Of Passing*</td>
                        <td class="style8">
                            <asp:DropDownList ID="DropDownList2" runat="server" Width="165px">
                                <asp:ListItem>Select Year Of Passing..</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                            ControlToValidate="DropDownList2" ErrorMessage="Enter Year Of Passing"
                                ValidationGroup="ld" InitialValue="Select Year Of Passing.."></asp:RequiredFieldValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Percentage Taken*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox10" runat="server"></asp:TextBox>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
                            ControlToValidate="TextBox10" ErrorMessage="Enter Percentage Taken"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Adddress*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox4" runat="server" Width="286px" TextMode="MultiLine"
                                Height="110px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                            ControlToValidate="TextBox4" ErrorMessage="Enter Address" ValidationGroup="ld"></asp:RequiredFieldValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Email-ID*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox5" runat="server" Width="286px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
                            ControlToValidate="TextBox5" ErrorMessage="Enter Email-ID"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                                runat="server" ControlToValidate="TextBox5" ErrorMessage="Enter Valid Email-ID"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                ValidationGroup="ld"></asp:RegularExpressionValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Telephone*</td>
                        <td class="style8">                           
                            <asp:TextBox ID="TextBox6" runat="server" Width="286px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
                            ControlToValidate="TextBox6" ErrorMessage="Enter Telephone"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2"
                                runat="server" ControlToValidate="TextBox6"
                                ErrorMessage="Enter Valid Telephone" ValidationExpression="\d{10}"
                                ValidationGroup="ld"></asp:RegularExpressionValidator>
                                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Login-ID*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox7" runat="server" Width="286px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
                            ControlToValidate="TextBox7" ErrorMessage="Enter Login-ID"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Password*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox8" runat="server" Width="286px" TextMode="Password"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
                            ControlToValidate="TextBox8" ErrorMessage="Enter Password"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            Confirm Password*</td>
                        <td class="style8">
                            <asp:TextBox ID="TextBox9" runat="server" Width="286px" TextMode="Password"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
                            ControlToValidate="TextBox9" ErrorMessage="Enter Confirm Password"
                                ValidationGroup="ld"></asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="CompareValidator1" runat="server"
                                ControlToCompare="TextBox8" ControlToValidate="TextBox9"
                                ErrorMessage="Password Doesn't Match" ValidationGroup="ld"></asp:CompareValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style6">
                            &nbsp;</td>
                        <td class="style8">
                            <asp:Button ID="Button1" runat="server" Text="Submit" ValidationGroup="ld" onclick="Button1_Click"
                                 />
                            <asp:Button ID="Button2" runat="server" Text="Reset" />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>

C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;

namespace HMSITFinal
{
    public partial class CSEStudentRegistration : System.Web.UI.Page
    {
        string cno = (string)ConfigurationSettings.AppSettings["con"];
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                for (int k = 2005; k <= Convert.ToInt32(DateTime.Now.Year); k++)
                {
                    DropDownList2.Items.Add(k.ToString());
                }
                get_Branch();
            }
        }
        public void get_Branch()
        {
            try
            {
                SqlConnection con = new SqlConnection(cno);
                con.Open();
                SqlCommand cmd = new SqlCommand("Select Branch_Name from tbl_WSS_UBE_Degree_Branch", con);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    DropDownList1.Items.Add(dr[0].ToString());
                }
                con.Close();
                con.Dispose();
            }
            catch
            {
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            insert_detail();
        }
        public void insert_detail()
        {
            try
            {
                string status = "Not Approved";
                SqlConnection con = new SqlConnection(cno);
                con.Open();
                SqlCommand cmd = new SqlCommand("insert into tbl_WSS_UBE_Placement_Student values('" + TextBox1.Text.Replace("'", "") + "','" + TextBox2.Text.Replace("'", "") + "','" + DropDownList1.Text + "','" + DropDownList2.Text.Replace("'", "") + "','" + TextBox4.Text.Replace("'", "") + "','" + TextBox5.Text.Replace("'", "") + "','" + TextBox6.Text.Replace("'", "") + "','" + TextBox7.Text.Replace("'", "") + "','" + TextBox8.Text.Replace("'", "") + "','" + TextBox10.Text + "','" + status.ToString() + "')", con);
                cmd.ExecuteNonQuery();
                send_mail();
                Response.Redirect("ThankYouCSE.aspx");
                con.Close();
                con.Dispose();
            }
            catch (Exception ex)
            {
                Literal1.Text = ex.Message + "Or May Be Roll Number/LoginID/Email-ID/Phone Number Exists in Our Database";
            }
        }
        public void send_mail()
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("hmsit.placement@gmail.com");
                mail.To.Add(TextBox5.Text);
                mail.Subject = "Thank You For Registration";
                mail.Body = "Dear " + TextBox2.Text + "\n\n  Your Request Has been Under Verification.As Soon As Possible You will Receive\n\n The Confirmation Message From Us If Your Detail Is Valid\n\n   Thanks and Regards\n\n    hmsit Placement";
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("hmsit.placement@gmail.com", "hmsit123");
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);

            }
            catch (Exception ex)
            {
                Literal1.Text = ex.Message;
            }
        }
    }
}
Then create thank page. 
 






ForgotPassword
PAGE 3 ForgotPassword.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Civil.Master" AutoEventWireup="true" CodeBehind="ForgotPassword.aspx.cs" Inherits="HMSITFinal.Civil_Engineering.ForgotPassword" %>


<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %>

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


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <table class="style3" style="width: 497px; font-size: small">
        <tr>
            <td>
               <h1> Recover The Password Here</h1></td>
        </tr>
        <tr>
            <td>
                <table class="style3" style="width: 487px">
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style6">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style5" style="text-align: right">
                            Enter Email-ID</td>
                        <td class="style6">
                            <asp:TextBox ID="TextBox8" runat="server" Width="261px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
                                ControlToValidate="TextBox8" ErrorMessage="Enter Valid Email-ID"
                                ValidationGroup="eid">*</asp:RequiredFieldValidator>
                                                     </td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style6">

                            <span class="style7">

                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                                ControlToValidate="TextBox8" ErrorMessage="Enter Valid Email-ID(tamagna@tamagna.com)"
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                ValidationGroup="eid"></asp:RegularExpressionValidator>
                                                     </td>
                        <td>
                            </span></td>
                    </tr>
                    <tr>
                        <td class="style5">
                            &nbsp;</td>
                        <td class="style6">
                            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit"
                                ValidationGroup="eid" />
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:Button ID="Button2" runat="server"  Text="CANCEL" onclick="Button2_Click"
                                 />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style10" colspan="3" style="color: #FFFFFF">
                            <asp:Literal ID="Literal2"
                        runat="server"></asp:Literal>
                        </td>
                    </tr>
                    <tr>
                        <td class="style10" colspan="3" style="color: #FFFFFF">
                            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                            </asp:ToolkitScriptManager>

                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
        </td>
        <td>
            &nbsp;</td>
    </tr>
</table>
</asp:Content>


C#

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Net.Mail;



namespace HMSITFinal.Civil_Engineering
{
    public partial class ForgotPassword : System.Web.UI.Page
    {
        string cn = (string)ConfigurationSettings.AppSettings["con"];
        int i;
        string sn, sc, did;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(cn);
            con.Open();
            SqlCommand cmd = new SqlCommand("Select Email_ID,Password from tbl_WSS_UBE_Placement_Student where Email_ID='" + TextBox8.Text.Replace("'", "") + "'", con);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                sn = dr[0].ToString();
                did = dr[1].ToString();
                send_mail();
            }
            else
            {
                Literal2.Text = "Entered Email-ID Doesn't Exists/Not Valid";
            }
            con.Close();
            con.Dispose();
        }
        public void send_mail()
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("hmsit.placement@gmail.com");
                mail.To.Add(sn.ToString());
                mail.Subject = "hmsit Password Recovery";
                mail.Body = "Dear Student,\n\n\n  Please Find Your Password\n\n\n" + did.ToString() + "\n\n\nThanks and Regards\n\n\n    hmsit Placement";
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("hmsit.placement@gmail.com", "hmsit123");
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);
                Literal2.Text = "Password Sent To You! Please Check Your Mail";
            }
            catch (Exception ex)
            {
                Literal2.Text = ex.Message;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("HomeCivil.aspx");
        }
    }
}




Login User Ip address
    //Login User Insertion
    public void Insert_LoginUsers(string userl)
    {
        try
        {

            string ClientIP = null;
            ClientIP = Request.UserHostAddress;
            SqlConnection con = new SqlConnection(cno);
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into tbl_UBE_LoginUser values('" + TextBox11.Text + "','" + DateTime.Now.ToString() + "','" + userl.ToString() + "','" + ClientIP.ToString() + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();
            con.Dispose();
        }
        catch
        {

        }

    }

No comments:

Tabs


Tab 1 content goes here

Tab 2 content goes here

Tab 3 content goes here
Multi-Tabbed Widget | DotNetIs