Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Dynamic dropdowns enable without post back

Dynamic dropdowns enable without post back

Scheduled Pinned Locked Moved Visual Basic
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    byka
    wrote on last edited by
    #1

    I have dymanuc drop down generated controls ( in some cases I can have as many as 5,3.... or none). If I have 3 drop downs then first needs to be enable and after they select 1 second and so on. How would I do this witout post back? Currently I am adding AddHandler ddlGroupStudentTypes.SelectedIndexChanged, AddressOf ddlGroupStudentTypesValueChanged

    D 1 Reply Last reply
    0
    • B byka

      I have dymanuc drop down generated controls ( in some cases I can have as many as 5,3.... or none). If I have 3 drop downs then first needs to be enable and after they select 1 second and so on. How would I do this witout post back? Currently I am adding AddHandler ddlGroupStudentTypes.SelectedIndexChanged, AddressOf ddlGroupStudentTypesValueChanged

      D Offline
      D Offline
      DannyStaten
      wrote on last edited by
      #2

      If your dropdowns are truly dynamic, then you are going to have to make a request from the server to get the next dropdown's values. In the most technical sense, that is a post to the server. I assume that you mean that you don't want to do a page refreshing style of a postback. In other words, you want an ajax call to load the data for the next dropdown. You have two general schools of thought you can go with: 1. UpdatePanel. This lets you run things through your server side events, and it disguises the postbacks so they don't make the page refresh. Pros are that it is simpler to implement. You basically can implement it as you would if you wanted the dropdowns to do a postback to load the next one. Then you wrap the dropdowns in an update panel, and set a few things and you are done. The update panel makes all those postbacks become ajax calls that don't refresh the page. Cons are that it is far less efficient in terms of bandwidth and server resources, and it can lead to some difficult debugging if you aren't familiar with the .net life cycle. Update panels result in a massive amount of auto generated javascript and additional markup being rendered to the browser which is not really ideal. Also, update panels only work for web forms applications, and are not available for MVC. I assume from what I saw in your question that you are doing web forms. 2. Ajax calls to web methods. Pros are that this is clean and efficient. You save tons on bandwidth consumption which can be a big deal for slow connection users. You also take a much lighter load on the server resources, which is a big deal for higher traffic solutions. You also are in much better control of what is rendered to the browser. Cons are that you have to know javascript a lot better than you would with update panels, and you have to take care of a few specifics that update panels abstract or take care of for you. I vastly prefer the 2nd option. If you go with the ajax option, then I can give you some additional pointers and things to look out for. I would suggest you use jquery and set up something like: in javascript: $("#myDropDown1Id").change(function(){ $.ajax({...//look at jquery.com for your specifics. You set your address, and send your parameters success:function(data){ //receive the data from your server and populate dropdown2 }, error:function(data){ //notify the user in some way });//end of .ajax });//end of change function Then you need to have a function exposed to be called as a web ser

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups