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. I have doubt regarding MasterPages & Content Pages...

I have doubt regarding MasterPages & Content Pages...

Scheduled Pinned Locked Moved ASP.NET
helpdesign
7 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.
  • R Offline
    R Offline
    Radiv Jeshya
    wrote on last edited by
    #1

    Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.

    R S S S 4 Replies Last reply
    0
    • R Radiv Jeshya

      Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.

      R Offline
      R Offline
      Radhakrishnan G
      wrote on last edited by
      #2

      Can you use validation controls, for validations.

      1 Reply Last reply
      0
      • R Radiv Jeshya

        Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.

        S Offline
        S Offline
        SeMartens
        wrote on last edited by
        #3

        Hi, there is a property for each control called ClientID (see here http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[^]). Use this property while generating the javascript, so that the controls can be accessed by this property. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        R 1 Reply Last reply
        0
        • S SeMartens

          Hi, there is a property for each control called ClientID (see here http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[^]). Use this property while generating the javascript, so that the controls can be accessed by this property. Regards Sebastian

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          R Offline
          R Offline
          Radiv Jeshya
          wrote on last edited by
          #4

          Thank you SeMartens for your immediate response,I would be more useful. If you provide a simple sample about how to access the controls in client side.

          S 1 Reply Last reply
          0
          • R Radiv Jeshya

            Thank you SeMartens for your immediate response,I would be more useful. If you provide a simple sample about how to access the controls in client side.

            S Offline
            S Offline
            SeMartens
            wrote on last edited by
            #5

            How do you attach the validation to the controls? If you have sth like a client-side event attached to the controls you can do sth like this: ASP-Code

            myTextbox.Attributes("onclick", "javascript:validateTextbox('" + myTextbox.ClientID + "')");

            and the javascript will look like this:

            validateTextbox(clientID) {
            var control = document.getElementByID(clientID);
            // do sth with the control -> validate etc.
            }

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            1 Reply Last reply
            0
            • R Radiv Jeshya

              Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.

              S Offline
              S Offline
              Sundar_R
              wrote on last edited by
              #6

              you can either read it this way document.getElementById("<%=Button1.ClientID%>") or set the master page id in page load of master page like this this.ID = "MyID"; then your control id will be MyID_contentplaceholderid_controlid also keep in mind that clientid wont work in js files

              1 Reply Last reply
              0
              • R Radiv Jeshya

                Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.

                S Offline
                S Offline
                SachinKumar M
                wrote on last edited by
                #7

                Use document.getElementById ("<%=TextBox1.ClientId%>").value

                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