Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Validation SetFocusOnErrorValidation SetFocusOnError
Previous
 
Next
New Post
11/24/2009 11:48 AM
 

 I've created a simple "Contact Us" type of module.  It takes in name, email, phone, etc.  All the normal stuff you'd expect in a contact us module.  The module itself works great, but I'm having a small problem with Validation.

I'm using RequiredFieldValidators for some fields that are needed (name, email, etc.).  Here's the one for the fi

<

asp:RequiredFieldValidator SetFocusOnError="true" Display="Static" ID="valFirstName" runat="server" ControlToValidate="txtFirstName" ErrorMessage="*Required Field"></asp:RequiredFieldValidator>

The validator itself works great.  When they click submit it displays *Required Field if the first name field is empty.  The problem is the form focus is not set to the txtFirstName text box as I expected it to.  I thought SetFocusOnError would do that for me, but it's not working.  Does anyone have any ideas?

 
New Post
11/24/2009 11:51 AM
 

The reason I want to set the focus to the missing field is so the user doesn't have to scroll back up the page to find the missing field.

 
New Post
12/4/2009 6:46 AM
 

To use SetFocusOnError for the Blank field u need to Take the Validation group and then assign each Validator a common validation group, take a look at my code i.e is how i implement it.

<div class="login">
                                <h4>Login to Site</h4>
                                <asp:label runat="server" id="UserNameLabel" CssClass="label" associatedcontrolid="UserName">User Name</asp:label>
                                <asp:TextBox runat="server" ID="UserName" CssClass="textbox" />
                                <asp:RequiredFieldValidator SetFocusOnError="true"    runat="server" ID="UserNameRequired" Display="None"  ControlToValidate="UserName" Text="" ValidationGroup="LoginControl" ErrorMessage="Username is requireds"></asp:Requiredfieldvalidator>
                                <asp:label runat="server" id="PasswordLabel" CssClass="label" associatedcontrolid="Password">Password</asp:label>
                                <asp:TextBox runat="server"    ID="Password" TextMode="Password" CssClass="textbox"/>
                                <asp:RequiredFieldValidator    runat="server" SetFocusOnError="true" ID="PasswordRequired" ErrorMessage="Password is required" Display="None" Text="" ValidationGroup="LoginControl" ControlToValidate="Password"></asp:Requiredfieldvalidator>
                                <div><asp:checkbox runat="server" id="RememberMe" text="Remember me    next time"/></div>
                                <asp:ImageButton runat="server" ValidationGroup="LoginControl"    ID="LoginButton" CausesValidation="true" CommandName="Login" AlternateText="login" skinid="login" CssClass="button"/>
                                or
                                <a href="register.aspx"    class="button"><asp:image id="Image1" runat="server" AlternateText="create    a new account" skinid="create"/></a>
                                <asp:ValidationSummary ID="vldLogin" runat="server" ShowSummary="false" ShowMessageBox="true" ValidationGroup="LoginControl" />
                                <p><asp:literal    runat="server" id="FailureText"    enableview_state="False"></asp:literal></p>
                            </div>

Hope it Helps


Amrish Sharma, MCP
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Validation SetFocusOnErrorValidation SetFocusOnError


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out