State, County, City dropdown using ASP.net and Javascript

Discussion in 'Programming' started by officialboss, May 22, 2007.

  1. #1
    I am searching for some ideas on how to populate my dropdowns on a search form that I am working on. I am using ASP.net 2.0 and C# with Access 2003 as the backend database.

    So far, I have thought of using AJAX with on each onselected index change on the dropdown to populate the other dropdowns. The data would be stored in the Access db.

    I like the way advanced search form on coldwellbanker.com populates and disables fields not needed using Javascript. I thought of implementing it like CWB but since I am using ASP.net 2.0 the client side ID of my dropdown controls change when the page is rendered, so the javascript has problems referring to the dropdowns.

    Do you guys have any ideas on best possible way to design this with ease and speed in mind.

    Thanks in advance.
     
    officialboss, May 22, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Well, you should not be worrying about the ClientSideID's at all

    First of all - only do your initial code if IsPostBack = false
    Then on ThatItem selectedIndexChange

    Everything shoudl be On postback events though (no ajax... people should see when/if the dropdown changes)

    So - I would do:

    If IsPostBack = False then
    ' Fill DropDownList1
    End if

    DropDownList1 OnSelectedIndexChange function
    ' Fill DropDownList2

    Etc... - and just let the ViewState take care of what items are set on postback :) ViewState is a beautiful thing when used correctly

    Best of luck!
     
    ccoonen, May 22, 2007 IP