On form submitting : Parameter count does not match Parameter Value count?

时间:2016-02-12 20:01:17

标签: asp.net sql-server sql-server-2008

I am trying to register on an asp site but I am getting following error as :

Registration Failed ! Parameter count does not match Parameter Value count

The Link Of Registration Page : https://myunitedforms.com/Registration.aspx

The Error Screen : enter image description here

You can look for yourself while to visit the page and apply for a signup at the end when submitting the form you will get the same error..!

I have access to hosting and here are the two source files as :

File Name : Registration.aspx

<%--<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>--%>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        var _SuccessMess;
        $(document).ready(function () {
            $('#ctl00_ContentPlaceHolder1_txtAgentWorkPhone').setMask({ mask: '(999) 999-9999', fixedChars: '[(),.:/ -]' }).watermark("(###)###-####");
            $('#ctl00_ContentPlaceHolder1_txtAgentCellphone').setMask({ mask: '(999) 999-9999', fixedChars: '[(),.:/ -]' }).watermark("(###)###-####");
            $("form").validate();
            if (_SuccessMess == 1) $(".message-success").show("slow");
            if (_SuccessMess == 0) $(".message-error").show("slow");
            $('#recaptcha_response_field').addClass('required');
            $('#recaptcha_response_field').val('required');
        });

        function validateCAPTCHA() {
            var response = $('#recaptcha_response_field').val();
            if (response == null || response == '') {
                $('#recaptcha_response_field').addClass('required error');
                return false;
            }
            else {
                return true;
            }
        }
    </script>
    <div class="box">
        <!-- box / title -->
        <div class="title">
            <h5>
                Registration</h5>
        </div>
        <!-- end box / title -->
        <div class="form">
            <div class="fields">
                <div class="field field-first">
                    <div class="label">
                        User Name
                    </div>
                    <div class="input">
                        <input runat="server" name="txtUserName" class="required" id="txtUserName" type="text">
                    </div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Password
                    </div>
                    <div class="input">
                        <input runat="server" name="txtPassword" class="required" id="txtPassword" type="password">
                    </div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Agent
                    </div>
                    <div class="input">
                        <input runat="server" size="75" name="txtAgent" class="required" id="txtAgent" type="text">
                    </div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Brokerage Firm
                    </div>
                    <div class="input">
                        <input runat="server" size="75" name="txtBrokerageFirm" class="required" id="txtBrokerageFirm"
                            type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Address
                    </div>
                    <div class="input">
                        <textarea runat="server" cols="75" rows="3" name="txtAgentWorkAddress" id="txtAgentWorkAddress" /></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        City
                    </div>
                    <div class="input">
                        <input runat="server" name="txtAgentCity" id="txtAgentCity" type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        State
                    </div>
                    <div class="input">
                        <input runat="server" name="txtAgentSt" id="txtAgentSt" type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Zip</div>
                    <div class="input">
                        <input runat="server" name="txtAgentZip" id="txtAgentZip" type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Phone
                    </div>
                    <div class="input">
                        <input runat="server" name="txtAgentWorkPhone" id="txtAgentWorkPhone" type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Cell
                    </div>
                    <div class="input">
                        <input runat="server" name="txtAgentCellphone" id="txtAgentCellphone" type="text"></div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Email
                    </div>
                    <div class="input">
                        <input id="txtAgentEmail" runat="server" size="75" class="required email" type="text" />
                    </div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        Docusign Email
                    </div>
                    <div class="input">
                        <input id="txtDocusignEmail" runat="server" size="75" class="email" type="text" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="box_captcha" style="padding: 0 0 0 20px; margin: -10px 0 0 0;">
        <recaptcha:RecaptchaControl ID="recaptcha" Theme="clean" runat="server" PublicKey="6Ld8vvMSAAAAALMXpOhqQIPHNKL1o_aLjDTzx7sY"
            PrivateKey="6Ld8vvMSAAAAAAFAIKpMMQfTDGb4RsIOi-01bfUj" />
    </div>
    <div class="box" style="margin: 0px 0 0 0;">
        <div class="form">
            <div class="fields">
                <div class="message message-success" id="message-success" style="display: none;">
                    <div class="image">
                        <img height="32" alt="Success" src="resources/images/icons/success.png" />
                    </div>
                    <div class="text">
                        <h6>Registration Successful !</h6>
                    </div>
                </div>
                <div class="message message-error" id="message-error" style="display: none;">
                    <div class="image">
                        <img height="32" alt="Error" src="resources/images/icons/error.png" />
                    </div>
                    <div class="text">
                        <h6>Registration Failed !</h6>
                        <asp:Label ID="lblErrorMessage" runat="server" Text=""></asp:Label>
                    </div>
                </div>
                <div class="field field-first">
                    <div class="label">
                        &nbsp;
                    </div>
                    <div>
                        <br />
                        <asp:Button ID="btnRegister" runat="server" Text="Register" OnClick="btnRegister_Click" OnClientClick="return validateCAPTCHA();" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>

And

File Name : Registration.aspx.cs

using GlobalLayer;
using System;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net.Mail;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Registration : Page, IRequiresSessionState
{


    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {
            recaptcha.Validate();
            if (!recaptcha.IsValid)
            {
                throw new Exception(recaptcha.ErrorMessage);
            }
            if (Page.IsValid)
            {
                lblErrorMessage.Text = "";
                DataSet dataBySP = new DataSet();
                object[] parameters = new object[] { this.txtUserName.Value, this.txtPassword.Value, this.txtAgent.Value, this.txtBrokerageFirm.Value, this.txtAgentWorkAddress.Value, this.txtAgentCity.Value, this.txtAgentSt.Value, this.txtAgentZip.Value, this.txtAgentWorkPhone.Value, this.txtAgentCellphone.Value, this.txtAgentEmail.Value, txtDocusignEmail.Value, 1, false, 0 };
                dataBySP = DAL.GetDataBySP("sp_RegisterUser", parameters);
                if ((dataBySP.Tables.Count > 0) && (dataBySP.Tables[0].Rows.Count > 0))
                {
                    UserData.UserID = dataBySP.Tables[0].Rows[0]["pk_UserId"].ToString();
                    UserData.UserName = dataBySP.Tables[0].Rows[0]["UserName"].ToString();

                    string validationKey = CustomEncryption.Encrypt(UserData.UserID + UserData.UserName + DateTime.Now.ToString());

                    object[] invParameters = new object[] { UserData.UserID, validationKey };
                    DAL.ExecuteSP("sp_SetUserInvitationKey", invParameters);

                    string emailsent = EmailUtility.NewUserEmail(UserData.UserID, this.txtAgentEmail.Value, HttpUtility.UrlEncode(validationKey), UserData.UserName);
                    if (emailsent != "success")
                    {
                        throw new Exception(emailsent);
                    }

                    base.Response.Redirect("AccountCreated.aspx");
                }
            }
            else
            {
                throw new Exception("Invalid page inputs.");
            }
        }
        catch (Exception exception)
        {
            this.lblErrorMessage.Text = exception.Message;
            ClientScript.RegisterClientScriptBlock(GetType(), "lblMessage123", "<script language=\"javascript\" type=\"text/javascript\">_SuccessMess=0;</script>");
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            (base.Master.FindControl("lblLoginUserName") as LinkButton).Text = "Guest";
            this.txtBrokerageFirm.Value = "United Real Estate Solutions, Inc";
            this.txtAgentWorkAddress.Value = "302 Jones St, Suite 100";
            this.txtAgentCity.Value = "Sioux City";
            this.txtAgentSt.Value = "IA";
            this.txtAgentZip.Value = "51101";
            this.txtAgentWorkPhone.Value = "(712) 226-6000";
        }
    }

    //private void SendMail()
    //{
    //    string str2 = File.ReadAllText(base.Server.MapPath("~/Template/RegistrationnEmail.htm")).Replace("@@UserName", this.txtUserName.Value.Trim()).Replace("@@Password", this.txtPassword.Value.Trim()).Replace("@@Agent", this.txtAgent.Value.Trim()).Replace("@@BrokerageFirm", this.txtBrokerageFirm.Value.Trim()).Replace("@@Address", this.txtAgentWorkAddress.Value.Trim()).Replace("@@City", this.txtAgentCity.Value.Trim()).Replace("@@State", this.txtAgentSt.Value.Trim()).Replace("@@Zip", this.txtAgentZip.Value.Trim()).Replace("@@Phone", this.txtAgentWorkPhone.Value.Trim()).Replace("@@Cell", this.txtAgentCellphone.Value.Trim());
    //    MailMessage message = new MailMessage {
    //        From = new MailAddress(ConfigurationManager.AppSettings["FromAddress"].ToString()),
    //        Subject = ConfigurationManager.AppSettings["Subject"].ToString(),
    //        IsBodyHtml = true,
    //        Body = str2
    //    };
    //    MailAddress item = new MailAddress(this.txtAgentEmail.Value.Trim());
    //    message.To.Add(item);
    //    new SmtpClient().Send(message);
    //}


}

As I am not familiar with asp.net as I am familiar with PHP so I need your help to let me know what is wrong with it and let me know how to fix it?

Here is sp_SetUserInvitationKey :

USE [CommercialSiteDB]
GO
/****** Object:  StoredProcedure [dbo].[sp_SetUserInvitationKey]    Script Date: 2/12/2016 11:38:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_SetUserInvitationKey]

    @UserId int,  
    @InvitationKey NVARCHAR(255)

AS

BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    UPDATE dbo.tbl_UserMaster_Mst set InvitationKey=@InvitationKey, InvitedOn=GETDATE(), IsLocked = 1
    Where pk_UserId = @UserID

END

The Screenshot as : enter image description here

enter image description here

Here is sp_RegisterUser :

USE [CommercialSiteDB]
GO
/****** Object:  StoredProcedure [dbo].[sp_RegisterUser]    Script Date: 2/13/2016 1:18:24 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_RegisterUser]
@UserName VARCHAR(50),  
@Password VARCHAR(50), 
@Agent VARCHAR(50), 
@BrokerageFirm VARCHAR(100), 
@Address VARCHAR(1000), 
@City VARCHAR(50), 
@State VARCHAR(50), 
@Zip VARCHAR(10), 
@Phone VARCHAR(15), 
@Cell VARCHAR(15), 
@Email VARCHAR(255), 
--@DocusignEmail varchar(255),
@Status TINYINT,
@UserID int
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

if(@UserID=0)
begin
        IF NOT EXISTS(SELECT pk_UserId FROM  dbo.tbl_UserMaster_Mst  WHERE UserName=@UserName )
        BEGIN
            INSERT INTO dbo.tbl_UserMaster_Mst (UserName, Password, Agent, BrokerageFirm, Address, City, State, Zip, Phone, Cell, Email, CreatedDateTime, ModifiedDateTime, Status)
            VALUES (@UserName, @Password, @Agent, @BrokerageFirm, @Address, @City, @State, @Zip, @Phone, @Cell, @Email, GETDATE(), GETDATE(), 1)   

            SELECT * FROM dbo.tbl_UserMaster_Mst WHERE pk_UserId=SCOPE_IDENTITY()
        END
        ELSE
        BEGIN
            RAISERROR ('Username already exist !', -- Message text.
                       16, -- Severity.
                       1 -- State.
                       );
        END
end
Else
begin
        IF NOT EXISTS(SELECT pk_UserId FROM  dbo.tbl_UserMaster_Mst  WHERE UserName=@UserName and pk_UserId <> @UserID)
        BEGIN
            Update dbo.tbl_UserMaster_Mst set UserName=@UserName, Password=@Password, Agent=@Agent, BrokerageFirm=@BrokerageFirm,
            Address=@Address, City=@City, State=@State, Zip=@Zip, Phone=@Phone, Cell=@Cell, Email=@Email, ModifiedDateTime=GETDATE()
            Where pk_UserId=@UserID

            SELECT * FROM dbo.tbl_UserMaster_Mst WHERE pk_UserId=@UserID
        END
        ELSE
        BEGIN
            RAISERROR ('Username already exist !', -- Message text.
                       16, -- Severity.
                       1 -- State.
                       );
        END
end


END

0 个答案:

没有答案