Solved

How requiredfieldvalidator only check one textbox in a aspx page with 6 textbox?

Posted on 2008-10-31
3
959 Views
Last Modified: 2012-06-27
I have 6 user control ascx pages, there is a textbox and submit button in each of them. I have a aspx page to include all those 6 user control pages.
I have a requiredfieldvalidator with onsubmit to check empty of all textbox. If the text box is empty and user clicks submit, it will be prompted.

Here is the aspx code

<asp:textbox id="text1" runat="server"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredText1" runat="server" EnableViewState="False" ControlToValidate="text1" Display="None" ErrorMessage="Please input 1"></asp:requiredfieldvalidator>
<asp:validationsummary id="ValidationSummary" runat="server" EnableViewState="False" ShowMessageBox="True" ShowSummary="False"></asp:validationsummary>
<asp:button id="button1" runat="server" text="submit"></asp:button>

<asp:textbox id="text2" runat="server"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredText2" runat="server" EnableViewState="False" ControlToValidate="text2" Display="None" ErrorMessage="Please input 2"></asp:requiredfieldvalidator>
<asp:validationsummary id="ValidationSummary" runat="server" EnableViewState="False" ShowMessageBox="True" ShowSummary="False"></asp:validationsummary>
<asp:button id="button2" runat="server" text="submit"></asp:button>

However, i just want to validate the onclick button, the remaining 5 textbox empty is ok. The code will prompt if one of six textbox is empty. So, I need to input text to all 6 textbox and it will not be prompted, how to solve it?

I use VC#

0
Comment
Question by:techques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:johnaryan
ID: 22848850
There should be an extended property on all the TextBoxes that allows you to not fire the Validator. I think it's the CausesValidation property.
0
 
LVL 3

Expert Comment

by:biodooms
ID: 22849040
So what you basically wish to do is submit if one of the 6 textboxes is filled? If that's the case then using an self made validation is the best solution.

do the following on button.click

if (!String.IsNullOrEmpty(Textbox1.Text) || (!String.IsNullOrEmpty(Textbox2.Text))
{
    //Do something
}
Else
{
    Errorlabel.visible = true;// The error label should be on the page with forcolor red and the error tekst.
    Errorlabel.databind();
}
0
 

Accepted Solution

by:
techques earned 0 total points
ID: 22850287
add ValidationGroup="Control1" to textbox, button and validation summary

and it works
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question