Solved

RequiredFieldValidator ErrorMessage not displaying after postback

Posted on 2011-02-16
2
894 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
[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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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