Adding dropdownlist options via Javascript

Discussion in 'ASP .Net Web Controls' started by dkehring, Jul 26, 2007.

  1. dkehring

    dkehring Guest

    Hi,

    Using VS.NET 2005...

    I created a custom web control based on the CompositeControl class. This
    control creates a table with two columns of DropDownList (DDL) objects. The
    DDL objects in the first column are populated with values on the server side.
    When the user selects an option from the DDL in the first column, I make an
    asychronous callback (AJAX) to a web service on the server to get a list of
    options for the selected value in the first DDL. The result of this call
    returns a string that I split into name/value pairs and use this to populate
    the adjacent DDL in the second column via Javascript. When I post back to the
    server, I want to be able to get the value selected in the second DDL. On
    postback I recreate the DDLs (by overriding CreateChildControls) but the
    second DDL does not show the selected value.

    To start, I added an event handler for the first DDL's SelectedIndexChanged
    event. When I trap this I get the value from the DDL and use this to load the
    list of values and populate the second DDL. However, the value coming back
    from postback does not "select" the option from the list. I figure that I'm
    not doing this at the right time in the page's life cycle but I can't figure
    out how to populate the second DDL prior to the selected value being set in
    the second DDL (which I assume happens during the LoadPostBackData method of
    the control).

    Any ideas how to handle this correctly?

    Regards,
    Dave
     
    dkehring, Jul 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cliff  Martin
    Replies:
    1
    Views:
    3,054
    Larry Smith
    Jan 31, 2007
  2. jacksu
    Replies:
    0
    Views:
    521
    jacksu
    Oct 9, 2007
  3. Utkado
    Replies:
    2
    Views:
    2,153
  4. Bryan Richardson
    Replies:
    6
    Views:
    299
    Bryan Richardson
    Feb 25, 2008
  5. Kevin Lyons
    Replies:
    12
    Views:
    199
    Dr John Stockton
    Oct 7, 2003
Loading...

Share This Page