cs file coding
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Data.Sql;
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;
public partial class changepassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submit_Click(object sender, EventArgs e)
{
string a, b;
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["sampleConnectionString2"].ToString();
SqlDataAdapter da = new SqlDataAdapter("select username,password from register where username='" + UserId.Text + "',password='" + Pwd.Text + "'",con);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Count; i++)
{
a = ds.Tables[0].Rows[i]["username"].ToString();
b = ds.Tables[0].Rows[i]["password"].ToString();
if (a == UserId.Text && b == Pwd.Text)
{
//SqlCommand cmd=new SqlCommand(
SqlDataAdapter sda = new SqlDataAdapter("update register set Password = '" + NPwd.Text.Trim() + "' where UserId ='" + UserId.Text + "'",con);
sda.Fill(ds);
Response.Write("<script language=Javascript>alert('Your Password Has Been Changed,Please Login With New Password')</script>");
}
else
{
Response.Write("<script language=Javascript>alert('password')</script>");
}
}
}
}
design coding
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="changepassword.aspx.cs" Inherits="changepassword" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Change Password</title>
</head>
<body bgcolor="#CCFFFF">
<center>
<h1><u>Online Shopping Cart</u></h1></center>
<form id="form1" runat="server">
<div>
<p align="center"><font size="5"><b>Change Password</b></font></p>
<asp:Panel style="position:absolute; top: 143px; left: 458px; height :182px; width: 340px; margin-top: 3px;" ID="Panel1"
runat="server" BackColor="Silver" BorderColor="#660033"
BorderStyle="Solid" HorizontalAlign="Center" ScrollBars="Vertical">
<table align="center" cellpadding="2" cellspacing="2" width="100%">
<tr>
<td style="padding-left:10px">
User ID</td>
<td>
<asp:TextBox ID="UserId" Runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:10px">
Old Password</td>
<td>
<asp:TextBox ID="Pwd" Runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:10px">
New Password</td>
<td>
<asp:TextBox ID="NPwd" Runat="server" CssClass="TblBorder" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td height="20" style="padding-left:10px">
Confirm Password </td>
<td>
<asp:TextBox ID="CPwd" Runat="server" CssClass="TblBorder" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td height="5">
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Submit" runat="server" OnClick="Submit_Click" />
<%--<asp:Button ID="Cancel" runat="server" OnClick="Cancel_Click" />
--%></td>
</tr>
</table>
</asp:Panel>
</div>
</form>
</body>
</html>
this code showing an error please rectify it
sankarreddy
reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator