Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 239981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:37:45+00:00 2026-05-11T20:37:45+00:00

I came across an interesting problem recently. In an ASP.NET Master Page, I have

  • 0

I came across an interesting problem recently. In an ASP.NET Master Page, I have a Login Control and a Google Search Box as shown below:

    <div id="searchBox">
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr><td> <asp:TextBox ID="q" MaxLength="100" AutoPostBack="false" runat="server" onclick="ctl00$q.value=''" CausesValidation="False" Text="Google Custom Search" /></td>
                           <td align="right">
                              <asp:ImageButton ID="_btnSearch" runat="server" AlternateText="Search" validationgroup="SearchGroup"
                                 CommandName="Search" ImageUrl="~/images/search.gif" OnClick="_btnSearch_Click"/>
                           </td>
                           <td width="5px" align="right">
                           <asp:RequiredFieldValidator ID="_rfvQ" ControlToValidate="q" runat="server" validationgroup="SearchGroup" />
<asp:HiddenField ID="cx" Value="00054535354544538:kmy_69vgpnm" runat="server" />
<asp:HiddenField ID="cof" Value="FORID:11" runat="server" /></td>
                        </tr>
                     </table>      
         </div>

Login Control

<asp:LoginView ID="LoginView1" runat="server">
        <AnonymousTemplate>
           <asp:Login ID="Login" runat="server" Width="100%" FailureAction="RedirectToLoginPage" meta:resourcekey="LoginResource1">
              <LayoutTemplate>
                 <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                       <td width="60px"><asp:Label runat="server" ID="lblUserName" AssociatedControlID="UserName" Text="Username:" meta:resourcekey="lblUserNameResource1" /></td>
                       <td><asp:TextBox id="UserName" runat="server" Width="95%" meta:resourcekey="UserNameResource2" /></td>
                       <td width="5px" align="right">
                          <asp:RequiredFieldValidator ID="valRequireUserName" runat="server" SetFocusOnError="True"
                             ControlToValidate="UserName" Text="*" ValidationGroup="Login" meta:resourcekey="valRequireUserNameResource1" />
                       </td>
                    </tr>
                    <tr>
                       <td style="height: 24px"><asp:Label runat="server" ID="lblPassword" AssociatedControlID="Password" Text="Password:" meta:resourcekey="lblPasswordResource1" /></td>
                       <td style="height: 24px"><asp:TextBox ID="Password" runat="server" TextMode="Password"  Width="95%" meta:resourcekey="PasswordResource2" /></td>
                       <td width="5px" align="right" style="height: 24px">
                          <asp:RequiredFieldValidator ID="valRequirePassword" runat="server" SetFocusOnError="True"
                             ControlToValidate="Password" Text="*" ValidationGroup="Login" meta:resourcekey="valRequirePasswordResource1" />
                       </td>
                    </tr>
                 </table>
                 <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                       <td><asp:CheckBox ID="RememberMe" runat="server" Text="Remember me" meta:resourcekey="RememberMeResource1"></asp:CheckBox></td>
                       <td align="right">
                          <asp:ImageButton ID="Submit" runat="server" AlternateText="Login"
                             CommandName="Login" ImageUrl="~/images/go.gif" ValidationGroup="Login" meta:resourcekey="SubmitResource1" />
                       </td>
                       <td width="5px" align="right">&nbsp;</td>
                    </tr>
                 </table>
                 <div style="border-top: solid 1px black; margin-top: 2px; padding-top: 2px">
                    <br />
                    <asp:HyperLink ID="lnkRegister" runat="server" NavigateUrl="~/Register.aspx" meta:resourcekey="lnkRegisterResource1" ForeColor="#104A9D" Text="Create new account"></asp:HyperLink><br />
                    <asp:HyperLink ID="lnkPasswordRecovery" runat="server" NavigateUrl="~/PasswordRecovery.aspx" meta:resourcekey="lnkPasswordRecoveryResource1" ForeColor="#104A9D" Text="I forgot my password"></asp:HyperLink>
                 </div>
              </LayoutTemplate>
           </asp:Login>
        </AnonymousTemplate>
        <LoggedInTemplate>
           <div id="welcomebox">
              <asp:LoginName ID="LoginName1" runat="server" FormatString="Hello {0}" meta:resourcekey="LoginName1Resource1" /><br />
              <small>
              <asp:HyperLink ID="lnkProfile" runat="server" Text="Edit Profile" NavigateUrl="~/EditProfile.aspx" meta:resourcekey="lnkProfileResource1" /><br /> 
              <asp:LoginStatus ID="LoginStatus1" Runat="server" meta:resourcekey="LoginStatus1Resource1" />
              </small>
           </div>
        </LoggedInTemplate>
     </asp:LoginView>

The search works fine if the user enters the text in the search text box and clicks the Search Button. However if the user enters the text in the search text box and hits the Enter button, then the validation for the Login control fires off. I want to avoid this since the user just wants to search.

How do I prevent the validation from firing when the user hits enter in the search text box.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:37:45+00:00Added an answer on May 11, 2026 at 8:37 pm

    You need to read about ValidationGroups. You might also want to change the default button- link text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have came across very interesting problem which I think it's on Salesforce's end
I have came across a very interesting problem. I have a UILabel and a
I came across an interesting problem today. I have a text email I'm sending
So I came across an interesting problem today. We have a WCF web service
I recently came across this interesting term and searched on Net to know more
I just came across the interesting problem of trying to trim the leading zeroes
I just came across an interesting problem with a procedure I am writing in
I came across an interesting problem today whilst implementing a feature into a dynamic
I'm using CodeIgniter and I came across an interesting problem. I need to use
I came across an interesting but rather annoying problem. I am trying to integrate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.