Solved

RequiredFieldValidator ErrorMessage not displaying after postback

Posted on 2011-02-16
2
888 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
ID: 34907704
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
ID: 34908401
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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