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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:07:43+00:00 2026-06-12T15:07:43+00:00

Hey all i am trying to figure out what i am doing incorrectly here.

  • 0

Hey all i am trying to figure out what i am doing incorrectly here. FYI i am new to ASP.net and its ways :o):

<asp:ListBox ID="df_dd_ccyear" name="df_dd_ccyear" style="z-index: 1000;" runat="server" ClientIDMode="Static">
      <script type="text/javascript">
         var d = new Date();
         var curr_year = d.getFullYear();
         var i = 1;

         while (i < 20) {
             if (i == 1) {
                 document.write('<asp:ListItem Text=\"' + (curr_year + i) + '\" value=\"' + (curr_year + i) + '\" Selected=\"True\"></asp:ListItem>');
             } else {
                 document.write('<asp:ListItem Text=\"' + (curr_year + i) + '\" value=\"' + (curr_year + i) + '\"></asp:ListItem>');
             }
             i++;
         }
      </script>
</asp:ListBox>

When running the page i receive this error:

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: System.Web.UI.WebControls.ListItemCollection must have items of type 'System.Web.UI.WebControls.ListItem'. 'script' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

Source Error: 


Line 200:                    <div id="df-ccyear" style="z-index: 1000;">
Line 201:                        <asp:ListBox ID="df_dd_ccyear" name="df_dd_ccyear" style="z-index: 1000;" runat="server" ClientIDMode="Static">
**Line 202:                            <script type="text/javascript">**
Line 203:                                var d = new Date();
Line 204:                                var curr_year = d.getFullYear();

Source File: /chattclub/default.aspx    Line: 202 
  • 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-12T15:07:44+00:00Added an answer on June 12, 2026 at 3:07 pm

    I suggest using Code behind always you can (as in this case). This way you can do the same like this:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim currentYear As Integer = Date.Now.Year
        For i As Integer = 0 To 19
            Dim newItem As New ListItem
            newItem.Text = currentYear + i
            newItem.Value = currentYear + i
            newItem.Selected = False
            If i = 0 Then
                newItem.Selected = True
            End If
            df_dd_ccyear.Items.Add(newItem)
        Next
    End Sub
    

    In the markup file (the .ASPX file), you just have to declare the ListBox like:

    <asp:ListBox ID="df_dd_ccyear" style="z-index: 1000;" runat="server" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey all, I'm very confused here, i've been trying to figure this one out.
Hey all i am in need of some help trying to figure out how
Hey all i am trying to figure out how to go about calculating this
Hey all, i am trying to figure out how to calculate the wage for
Hey all, i am in need of some help trying to figure out why
Hey all. I've been been trying to figure this out for a while now.
Hey all i am trying to figure out how to go about inserting a
Hey all i am trying to figure out a way to see what all
Hey I'm trying to figure something out.. I want to get all Carts that
Hey all i have been trying to figure out why i am getting this

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.