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. How to get Client ID of div tag in asp.net

How to get Client ID of div tag in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netsysadminhelp
8 Posts 5 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.
  • A Offline
    A Offline
    anish27patel
    wrote on last edited by
    #1

    Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.

    Anish Patel

    B A N R 4 Replies Last reply
    0
    • A anish27patel

      Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.

      Anish Patel

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      anish27patel wrote:

      var divId = document.getElementById('<% = Parent.ClientID %>');

      anish27patel wrote:

      i want to get clientID of div?

      Just simply use

      var divId = document.getElementById('YourDivID');

      You need ClienID for Server Side control. And i believe your div is in your client side .

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article

      A 1 Reply Last reply
      0
      • A anish27patel

        Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.

        Anish Patel

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        anish27patel wrote:

        <%=Parent.ClientID%>

        What is parent? Parent should be the ID of Div and should be runat=server.Is it so?

        Cheers!! Brij Check My Latest Article

        A 1 Reply Last reply
        0
        • B Brij

          anish27patel wrote:

          <%=Parent.ClientID%>

          What is parent? Parent should be the ID of Div and should be runat=server.Is it so?

          Cheers!! Brij Check My Latest Article

          A Offline
          A Offline
          anish27patel
          wrote on last edited by
          #4

          Thanks for your response Yes parent is id of div and i have given runat="server" with div tag for your information my script in common place like inside .js file and if i want to write same statement in page i get that ClientId so can you please help me out how can i get div client id in common js?

          Anish Patel

          B 1 Reply Last reply
          0
          • A Abhijit Jana

            anish27patel wrote:

            var divId = document.getElementById('<% = Parent.ClientID %>');

            anish27patel wrote:

            i want to get clientID of div?

            Just simply use

            var divId = document.getElementById('YourDivID');

            You need ClienID for Server Side control. And i believe your div is in your client side .

            cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article

            A Offline
            A Offline
            anish27patel
            wrote on last edited by
            #5

            Thanks for quick response but it's also return null can you please help me out ? for your more information my script in common palce like inside .js file Thanks

            Anish Patel

            1 Reply Last reply
            0
            • A anish27patel

              Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.

              Anish Patel

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              anish27patel wrote:

              var divId = document.getElementById('<%=Parent.ClientID%>');

              Where is the above code written? In the external JS file? If yes, it is not gonna work. You need move this to your page, get the client id and pass to your JS method which may be in external file. :)

              Navaneeth How to use google | Ask smart questions

              1 Reply Last reply
              0
              • A anish27patel

                Hello All, I want to get ClientID of Div tag in javascript so can you please help me for that? i have declare div with runat="server". -------- Javascript ----- var divId = document.getElementById('<%=Parent.ClientID%>'); but divId returns null So can you please help me how i want to get clientID of div? Thanks in Advance.

                Anish Patel

                R Offline
                R Offline
                r a m e s h
                wrote on last edited by
                #7

                You cannot use server side code like document.getElementById('<%=Parent.ClientID%>'); in your external .js file. Declare a global variable in your page and store the id of div tag in it. Then refer this variable in the .js file to get the client id. Declare this variable in your page: var yourDivId = '<%=Parent.ClientID%>'; Write this code in the .js file to get the above div id var objDiv = document.getElementById(yourDivId);

                1 Reply Last reply
                0
                • A anish27patel

                  Thanks for your response Yes parent is id of div and i have given runat="server" with div tag for your information my script in common place like inside .js file and if i want to write same statement in page i get that ClientId so can you please help me out how can i get div client id in common js?

                  Anish Patel

                  B Offline
                  B Offline
                  Brij
                  wrote on last edited by
                  #8

                  Are you the clientID of your div. Try this First assign the clientid in javascript variable like var hdnCtlSelectedItem = "<%=Parent.ClientID%>"; then check whether the you are getting the clientid.and pass this ID to javascript function i external JS file Afterthat access the divid using document.getElementById(hdnCtlSelectedItem);

                  Cheers!! Brij Check My Latest Article

                  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