Category Archives: CreateUserWizard

[RESOLVED] RequiredFieldValidator problem

Hello.
I need advice.
I have two dropdown lists and one textbox.
I have three RequiredFieldValidators.

And I need to do this. Create a JavaScript function that determines whether the validator RequiredFieldValidator1 is valid on the client side.

If one list is completed, so that species may not be completed.
How do I turn off RequiredFieldValidator1 RequiredFieldValidator2 and client-side?
How can I use javascript to check the validation of individual validator?

Thank you very much.

Hi,

It has been a while since i tackled validators in javascript.

There some asp.net objects and functions you can use, try looking them up to see how they work.

Page_Validators  - array of validators

ValidatorValidate - causes validation of a validator

ValidatorEnable - takes a boolean (i think) to turn on/off the validator (note, turning it on causes it to validate)

 

Regards

Si

If I wanted to show using javascript to view any error messages from all RequiredFieldValidators. In one window, using the alert.

For example: alert ('Error messages: '
Validators that are not valid. Their error messages.)

Please help.

Thank you.

Janko123

If I wanted to show using javascript to view any error messages from all RequiredFieldValidators. In one window, using the alert.

For example: alert ('Error messages: '
Validators that are not valid. Their error messages. )

 

 

check the below post to show alert messages from client side. no need of required field validators:

http://forums.asp.net/t/1641271.aspx/1?How+can+i+call+external+js+file+in+aspx+page+which+contains+the+master+page

 

check the post marked as answer at the end.

How to display error messages from a RequiredFieldValidator with Javascript?

 

<div class="SYN_ROW"> <div class="SYN_TXT" id="syn_row65" style="text-indent: -0.5em; padding-left: 1em;">The following ASP.NET mark-up:</div> <div class="SYN_TXT" style="text-indent: -0.5em; padding-left: 1em;">
<asp:TextBox runat="server" ID="txtName"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="rfvName" ControlToValidate="txtname" ErrorMessage="Name is required"></asp:RequiredFieldValidator></div> <div class="SYN_TXT" style="text-indent: -0.5em; padding-left: 1em;"></div> <div class="SYN_TXT" style="text-indent: -0.5em; padding-left: 1em;">is converted ito HTML as:</div> <div class="SYN_TXT" style="text-indent: -0.5em; padding-left: 1em;"></div> <div class="SYN_TXT" style="text-indent: -0.5em; padding-left: 1em;"><input name="txtName" type="text" id="txtName" /></div> </div> <div class="SYN_ROW"> <div class="SYN_TXT" id="syn_row66" style="text-indent: -0.5em; padding-left: 1em;"> <span id="rfvName" style="color:Red;visibility:hidden;">Name is required</span></div> </div>

 

 

So, from this, it is evident that the required field validators are converted into span tags when they are rendered by the server. The ID of the span tag is same as the ID of the required field validator. So, if you explore further, I think you will be able to find the way.

I think u haven't read my post properly. RequiredFieldValidator fires clientside i.e. they will show u messages before submitting the form if the form is true then it will go ahead otherwise not. u don't need to use javascript if using RequiredFieldValidator. see example here:

<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
         <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
                                    ControlToValidate="UserName" ErrorMessage="User Name is required."
                                    ValidationGroup="CreateUserWizard1"></asp:RequiredFieldValidator>

<asp:Button ID="Button1" runat="server" Text="Submit" ValidationGroup="CreateUserWizard1 />

 

now when u click 'Button1' It will automatically display ErrorMessage="User Name is required." if UserName is empty. u don't need to specify any javascript for this.

In my previous post I have given u link to show alert message not for requiredFieldValidator.

Now it is upto u to go with requiredFieldValidator or with alert message (own javascript) as my previous post.

[RESOLVED] Require help in captcha validation

<div style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; width: 100%; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; margin: 8px;">

Hi,

I have implemented captcha in my Register.aspx page. I am verifying captcha at server side. here is the code which is working fine.

 

 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        bool IsCaptcha;
        IsCaptcha = validateCaptcha();
        if (IsCaptcha == true)
        {
            StringBuilder bodyMsg = new StringBuilder();
            TextBox textBoxUserName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
            TextBox textBoxPassword = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password");
            TextBox textBoxEmail = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
            userName = textBoxUserName.Text;
            password = textBoxPassword.Text;
            email = textBoxEmail.Text;
            CreateUserWizard cuw = (CreateUserWizard)sender;
            MembershipUser user = Membership.GetUser(cuw.UserName);
            Guid userID = (Guid)user.ProviderUserKey;
             Response.Redirect("~/Thankyou.aspx");
        }
        else
             Response.Redirect("~/Register.aspx");
    }
    protected bool validateCaptcha()
    {
        TextBox textBoxCaptcha = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("TextBoxCaptcha");
        CaptchaControl captcha = (CaptchaControl)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ccJoin");
        captcha.ValidateCaptcha(textBoxCaptcha.Text);
        if (!captcha.UserValidated)
        {
           return false;
        }
        return true;
    }

 

The problem is that, I want to show the same page (i.e. Register.aspx) with all the fields intact except password field if captcha validation fails.

Also I want to show a * symbol next to the textbox where I am entering the captcha value for validation. Here is the code for that also

 

<asp:TextBox ID="TextBoxCaptcha" runat="server" CssClass="textEntry"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBoxCaptcha" 
              CssClass="failureNotification" ErrorMessage="*" ToolTip="Please verify that you are human." 
                      ValidationGroup="RegisterUserValidationGroup"></asp:RequiredFieldValidator>

Thanks,
Jatin

 

</div>

hallojatin

The problem is that, I want to show the same page (i.e. Register.aspx) with all the fields intact except password field if captcha validation fails.

In that case dont Response.Redirect("Register.aspx") on captcha failed....

hallojatin

Also I want to show a * symbol next to the textbox where I am entering the captcha value for validation. Here is the code for that also

I dont understand this question....

If I am not using this code Response.Redirect("Register.aspx") as suggested by you , I am getting below confirmation message if captcha validation fails. I know that the account is not updated in database but I dont want this confirmation message to appear. 

 Complete Your account has been successfully created. <input name="ctl00$MainContent$CreateUserWizard1$CompleteStepContainer$ContinueButtonButton" type="submit" value="Continue" id="ctl00_MainContent_CreateUserWizard1_CompleteStepContainer_ContinueButtonButton" />

The Next thing is that I want to show error message next to captcha when it fails.

hallojatin

 Complete Your account has been successfully created. <input id="ctl00_MainContent_CreateUserWizard1_CompleteStepContainer_ContinueButtonButton" value="Continue" type="submit" name="ctl00$MainContent$CreateUserWizard1$CompleteStepContainer$ContinueButtonButton" />

That depends where you are displaying this confirmation message.....simply check for captcha over there, in case captcha is ok then display confirmation message...or else just dont do it....

hallojatin

The Next thing is that I want to show error message next to captcha when it fails.

this can be done in multiple ways, the simple way is to put a label control beside captcha...and then write to it in case validation fails....

A simple example of captcha would be - 

http://www.intstrings.com/ramivemula/asp-net/simple-html-editor-based-comments-section-with-captcha-feature-along-with-database-interactivity/

Thanks.

I am not displaying any message when validation fails. That is the problem actually that I dont know why it comes and from where it comes. I beleive that it is the part of CreateUserWizard. Please see my below code that what I am doing

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        bool IsCaptcha;
        IsCaptcha = validateCaptcha();
        if (IsCaptcha == true)
        {
            StringBuilder bodyMsg = new StringBuilder();
            TextBox textBoxUserName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
            TextBox textBoxPassword = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password");
            TextBox textBoxEmail = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
            userName = textBoxUserName.Text;
            password = textBoxPassword.Text;
            email = textBoxEmail.Text;
            CreateUserWizard cuw = (CreateUserWizard)sender;
            MembershipUser user = Membership.GetUser(cuw.UserName);
            Guid userID = (Guid)user.ProviderUserKey;
            confirmationMailSender.createConfirmationBodyMessageForNewRegisteredUser(path, userID, bodyMsg, userName, password, email);
            Response.Redirect("~/Thankyou.aspx");
        }
      // now i am doing nothing on captcha val;idation failure but still getting the confirmation message.
       
    }

Hi,

hallojatin

That is the problem actually that I dont know why it comes and from where it comes. I beleive that it is the part of CreateUserWizard. Please see my below code that what I am doing

According to your code and description ,I get that you check the value of captcha in CreateUserWizard.CreatedUser event which occurs after the membership provider has created the new Web site user account.

Therefore ,whether captcha validation fails or not ,the message is displayed duo to the user account is created before checking the value of captcha.

For my experience ,you can try to check the value of captcha in CreateUserWizard.CreatingUser event which is raised before the membership provider is called to create the new Web site user account.

hallojatin

I have implemented captcha in my Register.aspx page

I would like to suggest you to check the link below for the similar thread which provides some solutions for adding captcha control to CreateUserWizard control.

http://forums.asp.net/t/1186626.aspx

Hope it can help you.

[RESOLVED] Setting a MaxLength for username field in CreateUserWizard Control

Hi

Is there a property i can call to set the maximum length for the username or password field in a CreateUserWizard Control to limit the numebr of characters entered in the field? If so, how can this be done?

Thanks

In the properties window of CreateUserWizard control choose Customize Create User Step and then you can set the maxlength property of username and password

In Page_Load method,

((TextBox)CreateUserWizard1.FindControl("CreateUserStepContainer").FindControl("UserName")).MaxLength = 10;

this will set the maxlength of the username field to 10.