Click here to Skip to main content
12,629,804 members (32,686 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET C#3.5
Dear Experts,
Can any one help to me..
i want to display the password in label through database..plzzz help me...

Dis is my source code..

<form id="form1" runat="server">
   <legend>Forgot Password</legend>
        <asp:Label ID="lblEmail" runat="server" Text="Email Address"></asp:Label>
    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RV1" runat="server" ControlToValidate="txtEmail" ErrorMessage="Please Enter Emailid"> *</asp:RequiredFieldValidator>
    <asp:Button ID="btnsubmit" runat="server" Text="Submit" onclick="btnsubmit_Click" />
        <asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>

my aspx.cs code:

protected void btnsubmit_Click(object sender, EventArgs e)

        SqlCommand cmd = new SqlCommand("Ldetails", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@EmailID", txtEmail.Text);

Posted 13-Sep-12 21:23pm
aspnet_regiis 14-Sep-12 2:26am
Wow. So if I know YOUR registered email id and I enter it in the txtEmail textbox and click Submit button, then I will get YOUR password.. Right? I never thought hacking was so easy..!!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I would strongly suggest not to implement such logic for retrieving lost password.

You should at no point display password in clear text (avoid storing clear passwords in DB too!)
For lost password case, either you send an email with new random password generated for the account or send old password to registered email.

Displaying password on screen is a big security loop hole.

Yet, if you want to, based on what you have shared, it looks like you try to get a password for given email address.
1. Get email address from user
2. Get password for the email from database
3. Show the data returned in step 2.

For 2 & 3, use ADO.NET, following article will help:
Beginners guide to accessing SQL Server through C#[^]
Accessing data with ADO.NET[^]
Member 9376025 14-Sep-12 2:37am
not by letters like stars it can display..
Sandeep Mewara 14-Sep-12 2:47am
How does that help? :) Totally flawed logic and implementation.

If that's what you seek, then just get the length/count of password letters and simply show that many starts in the UI. No need to retrieve password or so. Just the length.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

What is the function of your button to get data why are you using ExecuteNonQuery(),
use ExecuteReader() to get the password then display it to label
Member 9376025 14-Sep-12 4:26am
ya i used ExecuteReader(),
but not coming..
is there any changes in code..
CoderVivs 15-Sep-12 3:29am
are you getting the data from DB or not ?
if yes then make sure that your page postbacks +
keep the display label inside an UpdatePanel

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161205.3 | Last Updated 14 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100