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. acessing a user control's fields from a web page

acessing a user control's fields from a web page

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

    hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?

    S S 3 Replies Last reply
    0
    • S sohne

      hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?

      S Offline
      S Offline
      Subhasis Chandra
      wrote on last edited by
      #2

      From code behind try this.textboxname.Value (C#) Using javascript document.getElementById("textboxname").value Subhasis Chandra

      1 Reply Last reply
      0
      • S sohne

        hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?

        S Offline
        S Offline
        Sushant Duggal
        wrote on last edited by
        #3

        Hi, You can use as much levels of usercontrols as you like. You can simply get the value through javascript. "you have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox." place all these as these are written Then run the project. In the explorer, check the source of the page(view source : right click on internet explorer page and view source). Copy the ID for the textbox generated by the ASP.NET This ID never changes. Then add this function in the main web form WF_A (aspx): function getTextBoxValue() { alert(document.getElementById(UC_A:UC_B:TextBox1').value); } Call this function where you want to get the text, like OnClick of a Button : Button1.Attributes.Add("OnClick","javascript:getTextBoxValue()"); I feel this will help you. Thanks Sushant Duggal.

        1 Reply Last reply
        0
        • S sohne

          hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?

          S Offline
          S Offline
          Sushant Duggal
          wrote on last edited by
          #4

          I missed a quote here : alert(document.getElementById('UC_A:UC_B:TextBox1').value); Sushant Duggal.

          S 1 Reply Last reply
          0
          • S Sushant Duggal

            I missed a quote here : alert(document.getElementById('UC_A:UC_B:TextBox1').value); Sushant Duggal.

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

            i m using the method but not successful. The ':' is used in case of name and '_' is used in case of control ID.

            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