[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

asp.net validation controls letting bad data through

Posted on 2016-09-22
2
Medium Priority
?
50 Views
Last Modified: 2016-09-22
If I type xx into the textbox it violates the regular expression validator.  If I leave it blank, it violates the requiredfield validator.
In either case, I can simply ignore the messages and submit the form.
How can I give these controls the power to stop postback?

I'm using C# web forms with visual studio 2010.


 <asp:Label ID="lblExpectedProcessingDuration" runat="server" Text="ExpectedProcessingDuration" Font-Size="Small"  Width ="15%"></asp:Label>
    <asp:TextBox ID="TxtExpectedProcessingDuration" runat="server" 
        Font-Size="Small"  Width ="25%" MaxLength="4"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate ="TxtExpectedProcessingDuration" ErrorMessage="Please enter expected processing duration" Text ="*" Display="Dynamic" ValidationGroup="Something"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Expected processing duration must be numeric" 
            ControlToValidate="TxtExpectedProcessingDuration" Display="Dynamic" ValidationExpression="^[0-9]+$">
            </asp:RegularExpressionValidator>

Open in new window

0
Comment
Question by:AlHal2
[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
2 Comments
 
LVL 21

Accepted Solution

by:
Randy Poole earned 2000 total points
ID: 41810978
in your code behind for your save/submit button you would  do something like
 protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                SaveRecord();
            }
        }

Open in new window

0
 

Author Closing Comment

by:AlHal2
ID: 41811019
It's easy when you know how!  Thanks.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 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