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

  • SEARCH
  • Home
  • 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 6594639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:50:14+00:00 2026-05-25T17:50:14+00:00

<div> <asp:Label ID=lblClientId runat=server CssClass=label meta:resourcekey=lblClientIdResource /> <asp:TextBox ID=tbClientId runat=server style=width:150px; /> <asp:Button ID=btnClientId

  • 0
        <div>
            <asp:Label ID="lblClientId" runat="server" CssClass="label" meta:resourcekey="lblClientIdResource" /> 
            <asp:TextBox ID="tbClientId" runat="server"  style="width:150px; "/>
            <asp:Button ID="btnClientId" runat="server"  style="width:50px;" meta:resourcekey="btnClientIdResource" />
            <asp:CustomValidator ID="rfvClientId" runat="server" ValidationGroup="ClientId" meta:resourcekey="rfvClientIdResource" ControlToValidate="tbClientId" ClientValidationFunction="BtnClickClientId" style="position:absolute;"  ValidateEmptyText="True" ><asp:Image ID="Image2" ImageUrl="caution_20.png" runat="server" /></asp:CustomValidator>
       </div>



<script type="text/javascript">
        function BtnClickClientId(session, args) {
            ButtonClick(session, args, "<%= tbClientId.ClientID %>", "<%= lblClientId.ClientID %>");
        }
        window.onload = function () {
            document.getElementById('<%= tbClientId.ClientID%>').focus();
        };
    </script>


<asp:ValidationSummary ID="ClientIdValidationSummary" runat="server" BackColor="LightGray" DisplayMode="BulletList" CssClass="validationSummary" EnableClientScript="true" HeaderText='<%$ Resources:GlobalResource, ValidationSummaryResource %>'/>

So this ButtonClick() method is working and has been tested independently. The problem is that when i enter nothing into the text box and click the button, the validator works as expected and appears on the screen. Then it disappears. It is also never shown in the page validation summary. How do I get this to work?

I have tried to also set a required field validator on this text box and it seems to work with that but I do not want to use two validators.

     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbClientId" ErrorMessage="RequiredFieldValidator" style="position:absolute;"><asp:Image ID="Image2" ImageUrl="caution_20.png" runat="server" /></asp:RequiredFieldValidator>
            <asp:CustomValidator ID="rfvClientId" runat="server" ValidationGroup="ClientId" meta:resourcekey="rfvClientIdResource" ControlToValidate="tbClientId" ClientValidationFunction="BtnClickClientId" style="position:absolute;"  ValidateEmptyText="True" ></asp:CustomValidator>

This code works but I should not have to use 2 validators.

  • 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-25T17:50:15+00:00Added an answer on May 25, 2026 at 5:50 pm

    You need to set the “arg.IsValid” to “true” or “false” in the javascript function based on your requirement (i.e. to “true” when you think the validation is successful and false otherwise). Also, in the code behind file, it is always advisable to check for “Page.IsValid” property inside the click event handler of the button. So, in the javascript add this.

      arg.IsValid = false;
    

    and in code behind

      protected void button_click(..)
      {
           if (Page.IsValid)
           {
               // Your code, if any exists
           }
      }
    

    Hope this helps!!

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

Sidebar

Related Questions

<div style=height:100px;width:100%;overflow-x:hidden; overflow-y:scroll;> <asp:label id=lblInfo runat=server/> </div> My problem is vertical scroll always shown.
i have: <div id=question> <div style=float: left; width: 250px;> <asp:Label ID=question runat=server></asp:Label></div> <div> <asp:RadioButtonList
I've the following code: <asp:UpdatePanel runat=server ID=upanel1 > <ContentTemplate > <div id=west class=x-hide-display style=background-color:
I have written this datalist : <div class=story runat=server> <asp:DataList ID=DataList2 runat=server Height=16px Width=412px>
This is my code: <form id=form1 runat=server> <div> <asp:Label ID=Label1 runat=server Text=Label></asp:Label> <input type=button
i am using a label for showing error messages <div id=errorMessage> <asp:Label ID=lblError runat=server
<div id=divAnswerHeader> <div id=divAnswerSubHeader> <h2><asp:Label ID=lblTotalAnsw runat=server Text=></asp:Label> Answers</h2> <div id=divTabs> <asp:LinkButton ID=oldestAnswer runat=server
I have the following (trimmed) markup: <asp:Repeater ID=CostCategoryRepeater runat=server> <ItemTemplate> <div class=costCategory> <asp:Repeater ID=CostRepeater
I have the Progress bar div and the asp:label inside it. How to style
This is my full grid <div id=grid> <asp:GridView ID=gridProduct runat=server AutoGenerateColumns=false ShowFooter=true onrowcancelingedit=gridProduct_RowCancelingEdit onrowdeleting=gridProduct_RowDeleting

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.