Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I'm making a password change form . Below is the aspx:-

ASP.NET
<div class="container" id="passdiv">

        <div id="somemoredetail" class="row">

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="BtnSave" EventName="Click" />
                </Triggers>
                <ContentTemplate>


                    <h3 class="text-center">Change Password :-</h3>
                    <div class="clearfix separator"></div>

                    <asp:LinkButton ID="BtnSave" runat="server" class="btn btn-info" type="button" Text="Save"
                        Style="border-radius: 50%; height: 50px" OnClick="BtnSave_Click">
                    <span class="glyphicon glyphicon-floppy-save" style="margin-removed10px"></span>
                    </asp:LinkButton>


                    <div class="col-md-6 col-xs-12">

                        <div class="form-group text-center">
                            <div class="form-inline">
                                <p>
                                    User Name :-
                                 <asp:Label ID="user" runat="server" Text="User"></asp:Label>
                                </p>
                            </div>

                            <div class="form-inline">
                                <p>
                                    Old Password :-
                                    <asp:TextBox ID="old" TextMode="Password" runat="server" Style="border: 1px solid grey"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RqdFldVldoldpass" runat="server" ErrorMessage="Enter -- 'Old Password'" Text="#" ControlToValidate="old" ForeColor="Red"></asp:RequiredFieldValidator>
                                </p>
                            </div>
                            <div class="form-inline">
                                <p>
                                    New Password :-
                <asp:TextBox ID="newpass" TextMode="Password" Style="border: 1px solid grey" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RqdFldVldnewpass" runat="server" ErrorMessage="Enter -- 'New Password'" Text="#" ControlToValidate="newpass" ForeColor="Red"></asp:RequiredFieldValidator>
                                </p>
                            </div>
                            <div class="form-inline">
                                <p>
                                    Confirm New Password :-
                <asp:TextBox ID="confirmnew" TextMode="Password" Style="border: 1px solid grey" runat="server"></asp:TextBox>
                                    <asp:CompareValidator ID="ComparePassword" runat="server" ErrorMessage="New PassWord and Confirm New Password Don't Match" ControlToCompare="confirmnew" ControlToValidate="newpass" ForeColor="Red">#</asp:CompareValidator>
                                </p>
                            </div>
                        </div>

                    </div>


                </ContentTemplate>
            </asp:UpdatePanel>

        </div>


        <asp:ValidationSummary ID="ValidationSummaryPass" runat="server" ShowMessageBox="True" ShowSummary="False" />

    </div>


I've created a stored procedure to make changes for password:-

create proc passwrdchange
@ID bigint,
@oldpass varchar(MAX),
@newpass varchar(MAX),
@Out char output
As
Begin
Set @Out='F'

if(Select Password from User_Information where ID=@ID)=@oldpass
Begin
Update User_Information Set Password=@newpass,
@Out='T'
End

End

Now when I'm calling it via LINQ it's giving error "invalid arguments":-

C#
protected void BtnSave_Click(object sender, EventArgs e)
   {
        using(SampleDataContext dbContext=new SampleDataContext())
        {
            char outpt;
            int id = Convert.ToInt32(Session["USERID"]);
            dbContext.passwrdchange(id, old.Text, newpass.Text, ref outpt);
        }
   }


Please Help me With This.
Posted
Updated 25-Jan-16 1:44am
v2
Comments
Richard Deeming 25-Jan-16 8:24am    
You're storing passwords in plain text. That is an extremely bad idea. You should only ever store a salted hash of the password, using a unique salt per record.

Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]
Richard Deeming 25-Jan-16 8:25am    
Also, the last parameter should probably be out, not ref, since you haven't initialized it before calling the method.

If that doesn't solve the problem, then you'll need to post the signature of the passwrdchange method, and the full details of the error.
Deepak Kanswal Sharma 29-Jan-16 22:01pm    
I changed the parameter type from ref to out but nothing happened.
Deepak Kanswal Sharma 29-Jan-16 22:08pm    
It says :- The Best Overloaded method for 'SampleDataContext.passwrdchange(int?,string,string,ref char?)' has some invalid arguments.

This is my code for linq :-

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.passwrdchange")]
public int passwrdchange([global::System.Data.Linq.Mapping.ParameterAttribute(Name="ID", DbType="BigInt")] System.Nullable<int> iD, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="VarChar(MAX)")] string oldpass, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="VarChar(MAX)")] string newpass, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Out", DbType="Char(1)")] ref System.Nullable<char> @out)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iD, oldpass, newpass, @out);
@out = ((System.Nullable<char>)(result.GetParameterValue(3)));
return ((int)(result.ReturnValue));
}

1 solution

Finally I got the solution :-

C#
protected void BtnSave_Click(object sender, EventArgs e)
  {
      using (SampleDataContext dbContext = new SampleDataContext())
      {
          System.Nullable<char> outpt = null;
          long id = Convert.ToInt64(Session["USERID"]);
          dbContext.passwrdchange(id, old.Text.ToString().Trim(), newpass.Text.ToString().Trim(), ref outpt);

          if(outpt.ToString()=="T")
          {
              ClientScript.RegisterStartupScript(this.GetType(), "SuccessMsg", "<script>alert('Password Changed Successfully')</script>");
          }

          else
          {
              ClientScript.RegisterStartupScript(this.GetType(), "ErrorMsg", "<script>alert('Password Not Changed')</script>");
          }
      }
  }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900