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

  • Home
  • SEARCH
  • 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 7190795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:35:33+00:00 2026-05-28T19:35:33+00:00

I need to validate a DropDownList in an ASP.NET project and am trying to

  • 0

I need to validate a DropDownList in an ASP.NET project and am trying to use JavaScript even though I have never used it before.

I’m using the following ASP declaration and code JavaScript:

ASP declaration:

<asp:DropDownList ID="ddl1" runat="server" onprerender="ddl1_PreRender" ValidationGroup="AddNewCollection">
</asp:DropDownList>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Choose Type!"
ControlToValidate="ddl1"  ForeColor="Red" ValidationGroup="AddNewCollection" ClientValidationFunction="clientSideCheckValue"></asp:CustomValidator>>

JavaScript code:

 <script type="text/javascript">
    function clientSideCheckValue(source, args) 
     {
       var result1 = args.Value;   
       var rsult2 = document.getElementById("ddl1").value;
       if (result2 == null) {
          args.IsValid = false;
          return true;
       }
      args.IsValid = true;
    }
</script>

I have two questions about code mentioned above:

1.Why when I’m printing this row’s code var result1 = args.Value; intelisense dosen’t give me option to choose “Value” extension.

2.At this line of JavaScript code var rsult2 = document.getElementById(“ddl1”).value;

I get this error message Microsoft JScript runtime error: Object required.Have you got any idea why i meet this problem and how can i fix it?

Thank you in advance.

  • 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-05-28T19:35:34+00:00Added an answer on May 28, 2026 at 7:35 pm

    @Paul: “intelisense has no way of knowing what properties/methods args has, so it can’t give you the option.” Absolutely correct.

    @Michael:

    Assuming your JavaScript is in the .aspx markup, change your line to var rsult2 = document.getElementById(“<%=ddl1.ClientID” %>).value;. That will render the actual client ID of your DropDownList inside the script block.

    Also, you appear to be just making sure an option has been picked. It’s a lot easier to add an <asp:RequiredFieldValidator /> and set the ControlToValidate property to “ddl1” if that’s all you want to do.

    Hope this helps.

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

Sidebar

Related Questions

I need to validate TextBox based on Value selected in DropDownList controls. I have
I need to validate a url in variable with jQuery, but can't use validate-plugin.
I need to validate phone number in PHP. I have made following regex, but
I need to validate errors before it goes to action url of the form.
I need to validate serial numbers. For this we use regular expressions in C#,
I need validate multiple fields in the JavaScript Framework, but can't figure out how.
I need to validate time field in the textbox. I used this regular expression.
I need to validate the date format in textbox inside popup using JavaScript. Instead
i need to validate address1 , address 2 and city using jquery regex.. Used
I need to validate the zip code in java. I have googled and there

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.