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. User Control

User Control

Scheduled Pinned Locked Moved ASP.NET
tutorial
4 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
    aaraaayen 0
    wrote on last edited by
    #1

    Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,

    Prya

    B S D 3 Replies Last reply
    0
    • A aaraaayen 0

      Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,

      Prya

      B Offline
      B Offline
      blue_arc
      wrote on last edited by
      #2

      create object of that user control class, and and set the value of properties...

      1 Reply Last reply
      0
      • A aaraaayen 0

        Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,

        Prya

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        this.UserCtrl.TextBox1.value this way :)

        1 Reply Last reply
        0
        • A aaraaayen 0

          Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,

          Prya

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          As blue_arc said, you use user control from page codebehind same way as if it was standard ASP.NET web control. Assuming you have in your aspx file:

          <uc:userCtrl runat="server" id="myCtrl"/>
          

          in codebehind do:

          string password = myCtrl.pPass;
          

          Is it clear? :) You should not try to access textboxes directly, as it goes against encapsulation principle (hence I downvoted guy above me :P).


          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

          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