RequiredFieldValidator Codebehind Not Showing on ASPX?

Posted on 2009-02-12
Last Modified: 2012-05-06
I think my code is correct, but I think I'm experiencing a "container-n-container" issue. I click the button, but nothing shows on the aspx page. Not sure how to use the FindControl to locate the PlaceHolder. Help...

<table style="width: 100%; border: 0px solid #000000;" cellpadding="10px">
<asp:Panel ID="Panel3" runat="server">
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View2" runat="server">
<div style="text-align: left; float: left; padding: 20px;">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<asp:TextBox ID="txtName" runat="server" Visible="False" Width="144px"
<asp:PlaceHolder ID="phNameReqFieldVal" runat="server"></asp:PlaceHolder>

protected void Button1_Click(object sender, EventArgs e)
        RequiredFieldValidator rfdTxtName = new RequiredFieldValidator();
        rfdTxtName.Display = ValidatorDisplay.Static;
        rfdTxtName.ControlToValidate = "txtName";
        rfdTxtName.ErrorMessage = "Required Field!";
Question by:pointeman
    LVL 22

    Expert Comment

    1. RequiredFieldValidator should fire by itself.
    2. Why do you add your requiredfieldValidator in a PlaceHoder?

    Author Comment

    2. I want the error message to appear in a specific page area...
    LVL 22

    Accepted Solution

    Then use ValidationSummary control, instead of the PlaceHolder. You can put the ValidationSummary anywhere you like on your page.

    Author Comment

    I like the Validation Summary contol, but still not showing. I think its a panel issue again. I'm using masterpages and the contact.aspx has one panel containing all controls, including other panels...
    LVL 22

    Expert Comment

    So this ValidationSummary control is on the Contact.aspx page? Can you post your code here?

    Author Comment

    No, sorry for any confusion. I mean the textboxes are contained on the aspx page which has a main panel containing other panels, etc...
    LVL 22

    Expert Comment

    Some code will be helpful.

    Author Closing Comment

    ValidationSummary control makes life so much easier. Thanks...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    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…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now