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. get value from usercontrol

get value from usercontrol

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

    Hi, I have placed a usercontrol inside a .aspx page. The usercontrol has a label control called label1. Question: In the webform.cs, how do I get the value of the label control in the usercontrol? Thanks

    K S B 3 Replies Last reply
    0
    • A arkiboys

      Hi, I have placed a usercontrol inside a .aspx page. The usercontrol has a label control called label1. Question: In the webform.cs, how do I get the value of the label control in the usercontrol? Thanks

      K Offline
      K Offline
      ksss_maheshece
      wrote on last edited by
      #2

      You just use the following code Dim str as String str=ctype(usercontrolname.findcontrol("lable1"),lable).Text

      1 Reply Last reply
      0
      • A arkiboys

        Hi, I have placed a usercontrol inside a .aspx page. The usercontrol has a label control called label1. Question: In the webform.cs, how do I get the value of the label control in the usercontrol? Thanks

        S Offline
        S Offline
        saini arun
        wrote on last edited by
        #3

        Create a property in user control & access its value in .aspx page. in User control,

        public string TextValue
        {
        get{ return label1.Text; }
        }

        On .aspx page, you can get the label text as: string labelText = Userconrol1.TextValue;

        1 Reply Last reply
        0
        • A arkiboys

          Hi, I have placed a usercontrol inside a .aspx page. The usercontrol has a label control called label1. Question: In the webform.cs, how do I get the value of the label control in the usercontrol? Thanks

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

          As Arun said,having public property is a better and maintainable approach.

          Cheers!! Brij

          A 1 Reply Last reply
          0
          • B Brij

            As Arun said,having public property is a better and maintainable approach.

            Cheers!! Brij

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

            I do not seem to be able to access the usercontrol from the .aspx cs file. Note that the usercontrol1 is inside a folder called usercontrols. Any thoughts please? Thanks

            B 1 Reply Last reply
            0
            • A arkiboys

              I do not seem to be able to access the usercontrol from the .aspx cs file. Note that the usercontrol1 is inside a folder called usercontrols. Any thoughts please? Thanks

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

              Did you register the user control on the aspx page?If not First register it on your aspx page. else just go to design view of your aspx page and drag the usercontrol on your page it automatically register the control.Then you will be able to access the control from your aspx page.

              Cheers!! Brij

              A 1 Reply Last reply
              0
              • B Brij

                Did you register the user control on the aspx page?If not First register it on your aspx page. else just go to design view of your aspx page and drag the usercontrol on your page it automatically register the control.Then you will be able to access the control from your aspx page.

                Cheers!! Brij

                A Offline
                A Offline
                arkiboys
                wrote on last edited by
                #7

                Many thanks guys

                B 1 Reply Last reply
                0
                • A arkiboys

                  Many thanks guys

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

                  :)

                  Cheers!! Brij

                  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