Solved

RequiredFieldValidator ErrorMessage not displaying after postback

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

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…

740 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