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 805457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:05:00+00:00 2026-05-15T00:05:00+00:00

Greetings, In my current project, I have gridview, search button, text box for search,

  • 0

Greetings,
In my current project, I have gridview, search button, text box for search, text box, and submit button.

-I should input string in the search box then click search button.
-when click search button, it will retrieve all matches records then bind them to the view grid.

-then when I click a record in the gridview, it should bound a field to the second text box.

  • finally I should submit the page by clicking in submit button.
    where is the problem:

-the problme that I’m using jquery validation plugin that will make second text box is required.
-when I click search button will not allow postback until I write some thing in second text box.

How can I make scond text box only do validation for required field only when click asp.net submit button.

here is my code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="IMAM_APPLICATION.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

  <script src="js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>

    <script src="js/jquery.validate.js" type="text/javascript"></script>
    <script src="js/js.js" type="text/javascript"></script>

     <script type="text/javascript">
         $(document).ready(function() {



     $("#aspnetForm").validate({


            // debug: true,


             rules: {

             "<%=txtFirstName.UniqueID %>": {

                 required: true


             }

                 },
                   errorElement: "mydiv",
             wrapper: "mydiv",  // a wrapper around the error message

             errorPlacement: function(error, element) {
                 offset = element.offset();
                 error.insertBefore(element)
                 error.addClass('message');  // add a class to the wrapper
                 error.css('position', 'absolute');
                 error.css('left', offset.left + element.outerWidth());
                 error.css('top', offset.top - (element.height() / 2));

             }



         });
     })



</script>

     <div id="mydiv">
    <asp:GridView ID="GridView1" runat="server" 

                        style="position:absolute; top: 280px; left: 30px; height: 240px; width: 915px;" 
                        PageSize="5" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged" 
                        AutoGenerateColumns="False" DataKeyNames="idcontact_info">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" InsertVisible="False" 
                            ShowCancelButton="False" />
                        <asp:BoundField DataField="First_Name" HeaderText="First Name" />
                        <asp:BoundField AccessibleHeaderText="Midle Name" DataField="Midle_Name" />
                        <asp:BoundField DataField="Last_Name" HeaderText="Last Name" />
                        <asp:BoundField DataField="Phone_home" HeaderText="Phone Home" />
                        <asp:BoundField DataField="cell_home" HeaderText="Mobile Home" />
                        <asp:BoundField DataField="phone_work" HeaderText="Phone Work" />
                        <asp:BoundField DataField="cell_Work" HeaderText="Mobile Work" />
                        <asp:BoundField DataField="Email_Home" HeaderText="Personal Home" />
                        <asp:BoundField DataField="Email_work" HeaderText="Work Email" />
                    </Columns>
                </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        DeleteMethod="Delete" InsertMethod="Insert" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="IMAM_APPLICATION.DSContactTableAdapters.contact_infoTableAdapter" 
        UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_idcontact_info" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="First_Name" Type="String" />
            <asp:Parameter Name="Midle_Name" Type="String" />
            <asp:Parameter Name="Last_Name" Type="String" />
            <asp:Parameter Name="Address1_Home" Type="String" />
            <asp:Parameter Name="Address2_Home" Type="String" />
            <asp:Parameter Name="City_Home" Type="String" />
            <asp:Parameter Name="State_Home" Type="String" />
            <asp:Parameter Name="Prov_Home" Type="String" />
            <asp:Parameter Name="ZipCode_Home" Type="String" />
            <asp:Parameter Name="Country_Home" Type="String" />
            <asp:Parameter Name="Phone_home" Type="String" />
            <asp:Parameter Name="Phone_Home_Ext" Type="String" />
            <asp:Parameter Name="Cell_home" Type="String" />
            <asp:Parameter Name="Fax_home" Type="String" />
            <asp:Parameter Name="Email_Home" Type="String" />
            <asp:Parameter Name="material_status" Type="String" />
            <asp:Parameter Name="DateOfBrith" Type="String" />
            <asp:Parameter Name="company" Type="String" />
            <asp:Parameter Name="Work_Field" Type="String" />
            <asp:Parameter Name="Occupation" Type="String" />
            <asp:Parameter Name="sub_Occupation" Type="String" />
            <asp:Parameter Name="Other" Type="String" />
            <asp:Parameter Name="Address1_work" Type="String" />
            <asp:Parameter Name="Address2_work" Type="String" />
            <asp:Parameter Name="City_Work" Type="String" />
            <asp:Parameter Name="State_Work" Type="String" />
            <asp:Parameter Name="Prov_Work" Type="String" />
            <asp:Parameter Name="ZipCode_Work" Type="String" />
            <asp:Parameter Name="Country_Work" Type="String" />
            <asp:Parameter Name="Phone_Work" Type="String" />
            <asp:Parameter Name="Phone_Work_Ext" Type="String" />
            <asp:Parameter Name="Cell_Work" Type="String" />
            <asp:Parameter Name="Fax_Work" Type="String" />
            <asp:Parameter Name="Email_work" Type="String" />
            <asp:Parameter Name="WebSite" Type="String" />
            <asp:Parameter Name="Note" Type="String" />
            <asp:Parameter Name="Groups" Type="String" />
            <asp:Parameter Name="InterPhoneHome" Type="Int32" />
            <asp:Parameter Name="InterMobileHome" Type="Int32" />
            <asp:Parameter Name="InterFaxHome" Type="Int32" />
            <asp:Parameter Name="InterPhoneWork" Type="Int32" />
            <asp:Parameter Name="InterMobileWork" Type="Int32" />
            <asp:Parameter Name="InterFaxWork" Type="Int32" />
            <asp:Parameter Name="rdoPhoneHome" Type="Int32" />
            <asp:Parameter Name="rdoMobileHome" Type="Int32" />
            <asp:Parameter Name="rdoEmailHome" Type="Int32" />
            <asp:Parameter Name="rdoPhoneWork" Type="Int32" />
            <asp:Parameter Name="rdoMobileWork" Type="Int32" />
            <asp:Parameter Name="rdoEmailWork" Type="Int32" />
            <asp:Parameter Name="locationHome" Type="Int32" />
            <asp:Parameter Name="locationWork" Type="Int32" />
            <asp:Parameter Name="Original_idcontact_info" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="First_Name" Type="String" />
            <asp:Parameter Name="Midle_Name" Type="String" />
            <asp:Parameter Name="Last_Name" Type="String" />
            <asp:Parameter Name="Address1_Home" Type="String" />
            <asp:Parameter Name="Address2_Home" Type="String" />
            <asp:Parameter Name="City_Home" Type="String" />
            <asp:Parameter Name="State_Home" Type="String" />
            <asp:Parameter Name="Prov_Home" Type="String" />
            <asp:Parameter Name="ZipCode_Home" Type="String" />
            <asp:Parameter Name="Country_Home" Type="String" />
            <asp:Parameter Name="Phone_home" Type="String" />
            <asp:Parameter Name="Phone_Home_Ext" Type="String" />
            <asp:Parameter Name="Cell_home" Type="String" />
            <asp:Parameter Name="Fax_home" Type="String" />
            <asp:Parameter Name="Email_Home" Type="String" />
            <asp:Parameter Name="material_status" Type="String" />
            <asp:Parameter Name="DateOfBrith" Type="String" />
            <asp:Parameter Name="company" Type="String" />
            <asp:Parameter Name="Work_Field" Type="String" />
            <asp:Parameter Name="Occupation" Type="String" />
            <asp:Parameter Name="sub_Occupation" Type="String" />
            <asp:Parameter Name="Other" Type="String" />
            <asp:Parameter Name="Address1_work" Type="String" />
            <asp:Parameter Name="Address2_work" Type="String" />
            <asp:Parameter Name="City_Work" Type="String" />
            <asp:Parameter Name="State_Work" Type="String" />
            <asp:Parameter Name="Prov_Work" Type="String" />
            <asp:Parameter Name="ZipCode_Work" Type="String" />
            <asp:Parameter Name="Country_Work" Type="String" />
            <asp:Parameter Name="Phone_Work" Type="String" />
            <asp:Parameter Name="Phone_Work_Ext" Type="String" />
            <asp:Parameter Name="Cell_Work" Type="String" />
            <asp:Parameter Name="Fax_Work" Type="String" />
            <asp:Parameter Name="Email_work" Type="String" />
            <asp:Parameter Name="WebSite" Type="String" />
            <asp:Parameter Name="Note" Type="String" />
            <asp:Parameter Name="Groups" Type="String" />
            <asp:Parameter Name="InterPhoneHome" Type="Int32" />
            <asp:Parameter Name="InterMobileHome" Type="Int32" />
            <asp:Parameter Name="InterFaxHome" Type="Int32" />
            <asp:Parameter Name="InterPhoneWork" Type="Int32" />
            <asp:Parameter Name="InterMobileWork" Type="Int32" />
            <asp:Parameter Name="InterFaxWork" Type="Int32" />
            <asp:Parameter Name="rdoPhoneHome" Type="Int32" />
            <asp:Parameter Name="rdoMobileHome" Type="Int32" />
            <asp:Parameter Name="rdoEmailHome" Type="Int32" />
            <asp:Parameter Name="rdoPhoneWork" Type="Int32" />
            <asp:Parameter Name="rdoMobileWork" Type="Int32" />
            <asp:Parameter Name="rdoEmailWork" Type="Int32" />
            <asp:Parameter Name="locationHome" Type="Int32" />
            <asp:Parameter Name="locationWork" Type="Int32" />
        </InsertParameters>
    </asp:ObjectDataSource>

                    <asp:TextBox ID="txtSearch" runat="server" 
                    style="position:absolute; top: 560px; left: 170px;" ></asp:TextBox>

                    <asp:Button ID="btnSearch" runat="server" Text="Search" 
                    style="position:absolute; top: 555px; left: 375px;" 
                    CausesValidation="False" onclick="btnSearch_Click"/>

                    <asp:Label ID="Label7" runat="server" Style="position: absolute; top: 630px; left: 85px;"
                    Text="First Name"></asp:Label>

                 <asp:TextBox ID="txtFirstName" runat="server" Style="top: 630px; left: 185px; position: absolute;
                    height: 22px; width: 128px"></asp:TextBox>   
 <asp:Button ID="submit" runat="server" Text="submit" />



</div>    
</asp:Content>
  • 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-15T00:05:00+00:00Added an answer on May 15, 2026 at 12:05 am

    You can disable the submit blocking by default by passing the onsubmit option, like this:

     $("#aspnetForm").validate({
        onsubmit: false,
        rules: {
             "<%=txtFirstName.UniqueID %>": {
                 required: true
             }
    
        },
        errorElement: "mydiv",
        wrapper: "mydiv",
        errorPlacement: function(error, element) {
           offset = element.offset();
           error.insertBefore(element)
           error.addClass('message');  // add a class to the wrapper
           error.css('position', 'absolute');
           error.css('left', offset.left + element.outerWidth());
           error.css('top', offset.top - (element.height() / 2));
    
        }
     });
    

    Then call the .valid() method on only that button, like this:

    $("#<%=submit.ClientID%>").click(function() {
      return $("#aspnetForm").valid();
    });
    

    When you click the submit button specifically, you’re invoking validation, normally the validation plugin rigs up to the <form>‘s submit event, but setting onsubmit:false stops it from doing this. That leaves you to invoke validation whenever you want manually…which is what that .valid() call is doing, only on the button you want it on.

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

Sidebar

Related Questions

Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
Greetings, I have a particular object which can be constructed from a file, as
Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings. I'm looking for a way to parse a number of XML files in
Greetings! I'm working on wrapping my head around LINQ. If I had some XML
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings, I need a way (either via C# or in a .bat file) to
Greetings! I am trying to check directory write-permissions from within a Windows MFC/ATL program
Greetings, The VBA code below will create an Excel QueryTable object and display it
Greetings, currently I am refactoring one of my programs, and I found an interesting

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.