Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RequiredFieldValidator ErrorMessage not displaying after postback

Posted on 2011-02-16
2
Medium Priority
?
904 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 1000 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

Industry Leaders: 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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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