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. Why we are using ClientID while using master page ?

Why we are using ClientID while using master page ?

Scheduled Pinned Locked Moved ASP.NET
javascriptquestion
4 Posts 4 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.
  • M Offline
    M Offline
    md_azy
    wrote on last edited by
    #1

    if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?

    A A G 3 Replies Last reply
    0
    • M md_azy

      if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      md_azy wrote:

      Why we are using ClientID while using master page ?

      No idea, its your design, don't you know why you are doing it?

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • M md_azy

        if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Whenever you are using MasterPages, the master page can contain dvMyDiv into it. So if you call it with this name only, it will be calling the masterpage dvMyDiv. Generally after rendering the page, which is inside the masterpage, .NET prefix each control within the page with the masterpage placeholder name. Thus ambiguity could be removed by this. Thus from javascript if you want to find this control, you need to call the valid object, means contentplaceholdername_dvMyDiv. Otherwise you could replace the javascript call through the server tags with the appropriate client id. Check your view source, you will get the idea of what the id of the control looks like in your page.:rose:

        Abhishek Sur

        1 Reply Last reply
        0
        • M md_azy

          if we want to take value in control through javascript we will use var ds = document.getElementById("dvMyDiv").value ; if we are using master page means var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ; Why we are using ClientID while using master page ?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          md_azy wrote:

          Why we are using ClientID while using master page ?

          Whenever a server control is inside a container control (like the Content control used by content pages), the id of the container is prepended to the id of the control to ensure that every id in the page is unique. So, it's not only when you have a master page.

          Despite everything, the person most likely to be fooling you next is yourself.

          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