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 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 a decimal number in asp.net. I thought to use a
I am trying to use fluent validation with ASP.NET MVC project. I am trying
I need to validate TextBox based on Value selected in DropDownList controls. I have
I need to validate a phone number in javascript. The requirements are: they should
I need to validate a date string in a specific format in Javascript. The
I need validate multiple fields in the JavaScript Framework, but can't figure out how.
I need to validate my JAXB objects before marshalling to an XML file. Prior
I need to validate my Textbox by using Javascript. The TextBox shouldn't be null
I need to validate some variables values in Yii; I dont have a model
I need to validate the below range via regex in javascript. -20.00 to +20.00

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.