TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
271
36.2k
change password in asp.net using Entity Framework
Oct 15 2020 6:42 AM
i want when user wants to change password its first enter existing password then new password...
<table
class
=
"style1"
>
<tr>
<td>Current Password:</td>
<td>
<asp:TextBox ID=
"TxtCrntPswd"
runat=
"server"
></asp:TextBox>
</td>
</tr>
<tr>
<td>New Password:</td>
<td>
<asp:TextBox ID=
"TxtNwPswd"
runat=
"server"
></asp:TextBox>
</td>
</tr>
<tr>
<td>Confirm New Password:</td>
<td>
<asp:TextBox ID=
"TxtCnPswd"
runat=
"server"
></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID=
"RequiredFieldValidator1"
runat=
"server"
ControlToValidate=
"TxtCnPswd"
ErrorMessage=
"!!"
ForeColor=
"Red"
SetFocusOnError=
"True"
></asp:RequiredFieldValidator>
<asp:CompareValidator ID=
"CompareValidator1"
runat=
"server"
ControlToCompare=
"TxtNwPswd"
ControlToValidate=
"TxtCnPswd"
ErrorMessage=
"The new password and confirm password not same !!"
ForeColor=
"Red"
></asp:CompareValidator>
</td>
</tr>
</table>
</div>
<asp:Button ID=
"BtnPswd"
runat=
"server"
Text=
"Save"
OnClick=
"BtnPswd_Click"
/>
protected
void
BtnPswd_Click(
object
sender, EventArgs e)
{
using
(var context =
new
schoolEntities6())
{
string
strmsg =
string
.Empty;
byte
[] encode =
new
byte
[TxtCnPswd.Text.ToString().Length];
encode = Encoding.UTF8.GetBytes(TxtCnPswd.Text);
strmsg = Convert.ToBase64String(encode);
encrypwd = strmsg;
var currPass = TxtCrntPswd.Text;
var newPass = TxtNwPswd.Text;
var rePass = strmsg;
User userEntity = (from x
in
context.Users
where
x.Password == TxtCrntPswd.Text
select x).FirstOrDefault();
//if (userEntity != null)
{
userEntity.Password = TxtCnPswd.Text;
context.SaveChanges();
}
else
{
lbl_msg.Text =
"current password is incorrect"
;
}
}
This scenario isn't working
Reply
Answers (
1
)
how to insert data into many to many table using EF.
IIS Not including commas