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 127513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:29:19+00:00 2026-05-11T05:29:19+00:00

I have an asp.net page, some of its controls are created dynamically, these controls

  • 0

I have an asp.net page, some of its controls are created dynamically, these controls are one of the following; textbox, calendar, or dropdownlist.

These controls in some cases, should be validated based on flag read from db?

Is there any way to validate dynamically created controls?

  • 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. 2026-05-11T05:29:19+00:00Added an answer on May 11, 2026 at 5:29 am

    I got a solution for that problem. One of the main problems that I had with this page that it’s ajax-enabled and I need to validate dynamically created controls.

    My solution and it works properly, while creating the Control, I added an input attribute to it markes it as it is required or not, and another attribute that marks it as it is a field to be validated or not?

    Using Javascript, I go through all input tags with attribute ‘dynamic control’ and based on ‘to validate attribut’, I validate it or not. Simple, right?

    Sample Code: While control creating, mark it like the following

    txtBox.Attributes.Add('Type', 'T'); // Type of control. txtBox.Attributes.Add('IsKeyField', 'Y'); // Is dynamically created field. txtBox.Attributes.Add('IsMandatory', 'Y');  // Is mandatory or not? 

    JavaScript code

                var inputControls = document.getElementsByTagName('input');             for(var i=0 ; i<inputControls.length ; i++)             {                 if ( inputControls[i].getAttribute('IsKeyField') == 'Y' )                                                         {                     if (inputControls[i].getAttribute('Type') == 'T' || (inputControls[i].getAttribute('Type') == 'C'))                     {                         if(inputControls[i].getAttribute('IsMandatory') == 'Y')                         {                             if(inputControls[i].value == '')                             {                                 errorMsg += '\n' + inputControls[i].getAttribute('KeyField_Name') + ' is required.';                                 isValidated = false;                             }                                                     }                                              }                 }             } 

    Of course, you can call that code while clicking the required button.

    btnUpload.Attributes.Add('onClick', 'javascript:if(!ValidateMandatoryFields()) return false;'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a asp.net page with some user controls in it. One of the
I have an ASP.NET page using the AJAX control toolkit for some controls. A
I have ASP.NET page with an iframe on it for displaying some pdf reports
I have a normal asp.net page containing some code that I want to measure
We have a Web application (ASP.NET) which displays in some page links to miscellaneous
I have an ASP.Net Page, aspx with its default form. I have a Submit
I have an asp.net page within which I've used several AJAX controls doing partial
I have a button on my ASP.NET page, which fetches some data from my
I have an ASP.NET 3.5 page with some AJAX, some Validators and some business-rule
I have ASP.NET page, it calls webservice via $.ajax and returns result in json

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.