Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:41:02+00:00 2026-06-07T06:41:02+00:00

I have a user control with some custom client side validation. When I have

  • 0

I have a user control with some custom client side validation. When I have the user control on a page, it works no problem. But if that page has a postback event (select a certain option from a dropdown, and more fields are displayed), my validation no longer seems to work. My validation is as follows:

protected void Page_Load(object sender, EventArgs e)
{
    Type cstype = this.GetType();

    if (!Page.ClientScript.IsStartupScriptRegistered(cstype, "ValidatorType"))
    {
        String DateValidator;
        DateValidator = "<script type=\"text/javascript\">\n";
        DateValidator += "function ValidateDate(source, args) {\n";
        DateValidator += "   var ddDay = document.getElementById(source.day);\n";
        DateValidator += "   var day = ddDay.selectedIndex;";
        DateValidator += "   var ddMonth = document.getElementById(source.month);\n";
        DateValidator += "   var month = ddMonth.selectedIndex;\n";
        DateValidator += "   var ddYear = document.getElementById(source.year);\n";
        DateValidator += "   var year = ddYear.selectedIndex;\n";
        DateValidator += "   if (day == 0 || month == 0 || year == 0)\n";
        DateValidator += "      args.IsValid = false;\n";
        DateValidator += "   else\n";
        DateValidator += "      args.IsValid = true;\n";
        DateValidator += "   }\n";
        DateValidator += "</script>";
        Page.ClientScript.RegisterStartupScript(cstype, "ValidatorType", DateValidator);
    }
    Page.ClientScript.RegisterExpandoAttribute(reqDueDate.ClientID, "month", ddMonth.ClientID);
    Page.ClientScript.RegisterExpandoAttribute(reqDueDate.ClientID, "day", ddDay.ClientID);
    Page.ClientScript.RegisterExpandoAttribute(reqDueDate.ClientID, "year", ddYear.ClientID);
}

I’m stumped. Any advice?

EDIT:

Here is the User Control that I am using.

<asp:DropDownList ID="ddMonth" runat="server" AppendDataBoundItems="true">
   <asp:ListItem Value="">--Month--</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddDay" runat="server" AppendDataBoundItems="true">
    <asp:ListItem Value="">--Day--</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddYear" runat="server" AppendDataBoundItems="true">
    <asp:ListItem Value="">--Year--</asp:ListItem>
</asp:DropDownList>
<asp:CustomValidator ID="reqDueDate" EnableClientScript="true" ClientValidationFunction="ValidateDate" runat="server" ErrorMessage="Required" CssClass="input-notification error png_bg" Display="Dynamic"></asp:CustomValidator>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:41:04+00:00Added an answer on June 7, 2026 at 6:41 am

    Turns out, I needed to do 2 things. Put an Update Panel around in my user code, and change the lines

    Page.ClientScript.RegisterExpandoAttribute(reqDueDate.ClientID, "day", ddDay.ClientID);
    

    to

    ScriptManager.RegisterExpandoAttribute(UpdatePanelDDD, reqDueDate.ClientID, "day", ddDay.ClientID, false);
    

    Thanks all for your help and http://www.aspnetajaxtutorials.com/2010/09/customvalidator-registerexpandoattribut.html for the guidance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).
I have a custom user control which has some textboxes and some buttons. In
I have a custom user control that I am adding to a page via
I have a custom ASP.NET user control that is added to a panel on
I have a simple user control that contains some buttons that fire events which
I have been trying to build a user control with some custom properties set
I have an problem in Visual Studio 2010: I created an custom user control,
I have some custom user controls in my .net winforms program that do not
I have created a custom user control that is meant to extend the functionality
I have a user control which uses objects as inner properties (some code is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.