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. ClientID's ????

ClientID's ????

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelpquestion
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.
  • S Offline
    S Offline
    steffw
    wrote on last edited by
    #1

    Hello! I'm quite new to the ASP.NET world and I'm trying to build a menu with sub menu items, I know that their is a pre-build Menu control but I still want to create my own. I'm only facing the last problem. The clientID's? I've this recursive function: private Panel GetMenu(int ParentID) { stefw.Database.Page objPage = new stefw.Database.Page(); Panel pnlBox = new Panel(); DataTable dtItems = objPage.GetChildPages(ParentID); foreach (DataRow drItem in dtItems.Rows) { string url = "Default.aspx?Page=" + drItem["PageID"].ToString(); string name = drItem["Name"].ToString(); string link = "[" + name + "](\"")"; Panel pnlItem = new Panel(); pnlItem.ID = "Item" + drItem["PageID"].ToString(); pnlItem.Controls.Add(new LiteralControl(link)); pnlItem.CssClass = "Item"; if (drItem["HasChildren"].ToString() == "1") { Panel child = GetMenu(int.Parse(drItem["PageID"].ToString())); pnlBox.Attributes.Add("onMouseOver", "document.getElementByID('" + child.ClientID + "').style.overflow='visible'"); pnlItem.Controls.Add(child); } pnlBox.Controls.Add(pnlItem); } if (ParentID == -1) pnlBox.CssClass = "MainItem"; else pnlBox.CssClass = "Box"; pnlBox.ID = "Box" + ParentID.ToString(); return pnlBox; } and it gives this output: [Home](Default.aspx?Page=1) [Informatie](Default.aspx?Page=3) [Beheer](Default.aspx?Page=2) You can see that it goes wrong at this line: [document.getElementByID('Box1').style.overflow='visible'"] and here [pnlBox.Attributes.Add("onMouseOver", "document.getElemen

    E 1 Reply Last reply
    0
    • S steffw

      Hello! I'm quite new to the ASP.NET world and I'm trying to build a menu with sub menu items, I know that their is a pre-build Menu control but I still want to create my own. I'm only facing the last problem. The clientID's? I've this recursive function: private Panel GetMenu(int ParentID) { stefw.Database.Page objPage = new stefw.Database.Page(); Panel pnlBox = new Panel(); DataTable dtItems = objPage.GetChildPages(ParentID); foreach (DataRow drItem in dtItems.Rows) { string url = "Default.aspx?Page=" + drItem["PageID"].ToString(); string name = drItem["Name"].ToString(); string link = "[" + name + "](\"")"; Panel pnlItem = new Panel(); pnlItem.ID = "Item" + drItem["PageID"].ToString(); pnlItem.Controls.Add(new LiteralControl(link)); pnlItem.CssClass = "Item"; if (drItem["HasChildren"].ToString() == "1") { Panel child = GetMenu(int.Parse(drItem["PageID"].ToString())); pnlBox.Attributes.Add("onMouseOver", "document.getElementByID('" + child.ClientID + "').style.overflow='visible'"); pnlItem.Controls.Add(child); } pnlBox.Controls.Add(pnlItem); } if (ParentID == -1) pnlBox.CssClass = "MainItem"; else pnlBox.CssClass = "Box"; pnlBox.ID = "Box" + ParentID.ToString(); return pnlBox; } and it gives this output: [Home](Default.aspx?Page=1) [Informatie](Default.aspx?Page=3) [Beheer](Default.aspx?Page=2) You can see that it goes wrong at this line: [document.getElementByID('Box1').style.overflow='visible'"] and here [pnlBox.Attributes.Add("onMouseOver", "document.getElemen

      E Offline
      E Offline
      eggsovereasy
      wrote on last edited by
      #2

      ClientID is the id that the client sees. If you look at the source of your page from the browser (after it has been processed) your id's get changed to things like ctl00_YourID. There is a property for the controls called ClientID that you can assign the id so that you can access it with javascript on the client (this only matters for controls with runat="server").

      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