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 access server-side controls of a user control(ascx) from its parent page (aspx) by using javascript

How to access server-side controls of a user control(ascx) from its parent page (aspx) by using javascript

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmintutorial
13 Posts 3 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
    Bluebamboo
    wrote on last edited by
    #1

    Hi all, I have already found the approaches to access server-side controls of a user control (e.g asp:label asp:textbox ...) on IE, var obj = document.getElementById('uctAUserConrolID_AServerSideControlID'); //or var obj = document.getElementById('uctAUserConrolID:AServerSideControlID'); //or BUT, these approaches don't work on Firefox!!! :( please let me know if anyone know the answer. Thanks Ming

    P M 2 Replies Last reply
    0
    • B Bluebamboo

      Hi all, I have already found the approaches to access server-side controls of a user control (e.g asp:label asp:textbox ...) on IE, var obj = document.getElementById('uctAUserConrolID_AServerSideControlID'); //or var obj = document.getElementById('uctAUserConrolID:AServerSideControlID'); //or BUT, these approaches don't work on Firefox!!! :( please let me know if anyone know the answer. Thanks Ming

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      Correct me if i'm wrong, but firefox doesn't use getElementbyId, does it?

      B M 3 Replies Last reply
      0
      • P Paddy Boyd

        Correct me if i'm wrong, but firefox doesn't use getElementbyId, does it?

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

        Hi, The firefox do use getElementbyId, because I tried this piece of code below to get the client-side controls within a user control , it works. var obj = document.getElementById('AClientSideControl');

        1 Reply Last reply
        0
        • P Paddy Boyd

          Correct me if i'm wrong, but firefox doesn't use getElementbyId, does it?

          B Offline
          B Offline
          Bluebamboo
          wrote on last edited by
          #4

          By the way,I use the latest version of firefox.

          1 Reply Last reply
          0
          • P Paddy Boyd

            Correct me if i'm wrong, but firefox doesn't use getElementbyId, does it?

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            Firefox uses getElementById.

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

            P 1 Reply Last reply
            0
            • M Michael Sync

              Firefox uses getElementById.

              Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

              P Offline
              P Offline
              Paddy Boyd
              wrote on last edited by
              #6

              It would appear that indeed i am wrong... :)

              1 Reply Last reply
              0
              • B Bluebamboo

                Hi all, I have already found the approaches to access server-side controls of a user control (e.g asp:label asp:textbox ...) on IE, var obj = document.getElementById('uctAUserConrolID_AServerSideControlID'); //or var obj = document.getElementById('uctAUserConrolID:AServerSideControlID'); //or BUT, these approaches don't work on Firefox!!! :( please let me know if anyone know the answer. Thanks Ming

                M Offline
                M Offline
                Michael Sync
                wrote on last edited by
                #7

                You can view the HTML ViewSource in both IE and Firefox. And find out what the name of your element. then, I think you will get some idea how to get the object of your element in Javascript. If not, can you please the name of your name which is shown in the viewsource of IE and Firefox.

                Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                B 2 Replies Last reply
                0
                • M Michael Sync

                  You can view the HTML ViewSource in both IE and Firefox. And find out what the name of your element. then, I think you will get some idea how to get the object of your element in Javascript. If not, can you please the name of your name which is shown in the viewsource of IE and Firefox.

                  Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

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

                  Hi Michael, Thanks for your help, I did use the way you suggested. The HTML ViewSource for the asp:net control in both IE and Firefox are actually same: :doh: For Firefox: For IE: Regards, Ming

                  M 1 Reply Last reply
                  0
                  • B Bluebamboo

                    Hi Michael, Thanks for your help, I did use the way you suggested. The HTML ViewSource for the asp:net control in both IE and Firefox are actually same: :doh: For Firefox: For IE: Regards, Ming

                    M Offline
                    M Offline
                    Michael Sync
                    wrote on last edited by
                    #9

                    var obj = document.getElementById("UctLogin1_txtEmail"); doesn't work? You got the error or got nothing? Have you tried to debug your javascript by using Firebug?

                    Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                    B 1 Reply Last reply
                    0
                    • M Michael Sync

                      You can view the HTML ViewSource in both IE and Firefox. And find out what the name of your element. then, I think you will get some idea how to get the object of your element in Javascript. If not, can you please the name of your name which is shown in the viewsource of IE and Firefox.

                      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                      B Offline
                      B Offline
                      Bluebamboo
                      wrote on last edited by
                      #10

                      Hi Michael, Problems solved, I use getElementsByName with its name in HTML ViewSource instead of ID, it works! ;) It seems like the getElimentById function still does not work compatiblely with firefox very well. Regards, Ming

                      M B 2 Replies Last reply
                      0
                      • M Michael Sync

                        var obj = document.getElementById("UctLogin1_txtEmail"); doesn't work? You got the error or got nothing? Have you tried to debug your javascript by using Firebug?

                        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                        B Offline
                        B Offline
                        Bluebamboo
                        wrote on last edited by
                        #11

                        No, it doesn't work with getElementById, no error shown in Firefox error console. the result show null. but anyway, getElementsByName works .. :laugh:

                        1 Reply Last reply
                        0
                        • B Bluebamboo

                          Hi Michael, Problems solved, I use getElementsByName with its name in HTML ViewSource instead of ID, it works! ;) It seems like the getElimentById function still does not work compatiblely with firefox very well. Regards, Ming

                          M Offline
                          M Offline
                          Michael Sync
                          wrote on last edited by
                          #12

                          :) okay.. great!

                          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

                          1 Reply Last reply
                          0
                          • B Bluebamboo

                            Hi Michael, Problems solved, I use getElementsByName with its name in HTML ViewSource instead of ID, it works! ;) It seems like the getElimentById function still does not work compatiblely with firefox very well. Regards, Ming

                            B Offline
                            B Offline
                            Bluebamboo
                            wrote on last edited by
                            #13

                            Oh dear! I just found out what I said was wrong. getElementById function works as well!! :omg:

                            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