Solved

RequiredFieldValidator ErrorMessage not displaying after postback

Posted on 2011-02-16
2
879 Views
Last Modified: 2012-05-11
Experts,

I have a few RequiredFieldValidators on my web form. EnableClientScript = False. If there is an error, the error message of the RequiredFieldValidator does not display on PostBack. Currently an alertbox displays informing the user of an error, but it's not obvious where on the form the error is. Am I overlooking something obvious or am I just not using this control correctly?

Thanks in advance.
0
Comment
Question by:jvoconnell
2 Comments
 
LVL 9

Accepted Solution

by:
gdupadhyay earned 250 total points
Comment Utility
Please use below example and see following URL for more info.

http://asp.net-tutorials.com/validation/required-field-validator/
<form id="form1" runat="server">
    Your name:<br />
    <asp:TextBox runat="server" id="txtName" />
    <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your name!" />
    <br /><br />
    <asp:Button runat="server" id="btnSubmitForm" text="Ok" />
</form>

Button:
-------

<asp:Button runat="server" id="btnSubmitForm" text="Ok" onclick="btnSubmitForm_Click" />


.cs page
----------

protected void btnSubmitForm_Click(object sender, EventArgs e)
{
    if(Page.IsValid)
    {
        btnSubmitForm.Text = "My form is valid!";
    }
}

Open in new window

0
 
LVL 1

Author Comment

by:jvoconnell
Comment Utility
Hello qdupadhyay. What I had appeared to be correct. But obviously not.  I still don't know what I was doing wrong. But when I cut/pasted your code and changed the target names, it worked. A lot of wasted time on my end. Thank you very much. I can finally move on. THis is very much appreciated!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now