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. Web Development
  3. ASP.NET
  4. Set Listbox scroll position after Postback

Set Listbox scroll position after Postback

Scheduled Pinned Locked Moved ASP.NET
databasetoolsquestionannouncement
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.
  • D Offline
    D Offline
    dsrao
    wrote on last edited by
    #1

    Hi All, I have a muti-select listbox on my web form. When you scroll down to select items and SelectIndexChanged event fires, the postback brings the listbox back to the top of the screen. The item is still selected, but you have to scroll down to see it. How do I get the listbox to show one of the currently selected items. Below is the my code.. aspx page ]]> AutoPostBack="true" Width="150px" OnSelectedIndexChanged="cmdCustomList_SelectedInde xChanged"> client script fuction CustomSelect() { Var SMIndex = document.getElementById('ctl00_ContentPlaceHolder1 _cmdCustomList'); for(var index = 0; index < SMIndex.options.length; index++) { if (SMIndex.options[index].selected) { SMIndex.options[index].selected = true; } } } Code behind protected void cmdCustomList_SelectedIndexChanged(object sender, EventArgs e) int cntSelected = 0; string scriptBlock = "CustomSelect();"; try { if (cmdCustomList.SelectedIndex > -1) { for (int indx = 0; indx<cmdcustomlist.items.count;>{ if (cmdCustomList.Items[indx].Selected == true) { values = values + "," + cmdCustomList.Items[indx].Value; cntSelected++; } } Session["lstCompHosp"] = values; if (chkComparisonExcludeOnly.Checked == false) { if (cntSelected == cmdCustomList.Items.Count) scriptBlock = "cmdAllAvailHosp();" // Another Client side function } updpanelComparisonHospital.Update(); ScriptManager.RegisterStartupScript(this, typeof(DefaultView), "cmdCustom", scriptBlock, true); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } } Would you please give some directions. Thanks Rao

    Thanks & Regards Rao

    R 1 Reply Last reply
    0
    • D dsrao

      Hi All, I have a muti-select listbox on my web form. When you scroll down to select items and SelectIndexChanged event fires, the postback brings the listbox back to the top of the screen. The item is still selected, but you have to scroll down to see it. How do I get the listbox to show one of the currently selected items. Below is the my code.. aspx page ]]> AutoPostBack="true" Width="150px" OnSelectedIndexChanged="cmdCustomList_SelectedInde xChanged"> client script fuction CustomSelect() { Var SMIndex = document.getElementById('ctl00_ContentPlaceHolder1 _cmdCustomList'); for(var index = 0; index < SMIndex.options.length; index++) { if (SMIndex.options[index].selected) { SMIndex.options[index].selected = true; } } } Code behind protected void cmdCustomList_SelectedIndexChanged(object sender, EventArgs e) int cntSelected = 0; string scriptBlock = "CustomSelect();"; try { if (cmdCustomList.SelectedIndex > -1) { for (int indx = 0; indx<cmdcustomlist.items.count;>{ if (cmdCustomList.Items[indx].Selected == true) { values = values + "," + cmdCustomList.Items[indx].Value; cntSelected++; } } Session["lstCompHosp"] = values; if (chkComparisonExcludeOnly.Checked == false) { if (cntSelected == cmdCustomList.Items.Count) scriptBlock = "cmdAllAvailHosp();" // Another Client side function } updpanelComparisonHospital.Update(); ScriptManager.RegisterStartupScript(this, typeof(DefaultView), "cmdCustom", scriptBlock, true); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } } Would you please give some directions. Thanks Rao

      Thanks & Regards Rao

      R Offline
      R Offline
      Rajdev Ramasamy
      wrote on last edited by
      #2

      Please check whether this link will be useful: http://forums.asp.net/p/1324500/2665985.aspx[^] Regards, Rajdev KR

      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