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. accessing textbox which is inside ascx file

accessing textbox which is inside ascx file

Scheduled Pinned Locked Moved ASP.NET
helpquestion
20 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.
  • D Dhyanga

    hello i have a problem in accessing textbox from its usercontrol. i have textbox in the user control i.e in ascx file and now i want to use that textbox value in the aspx page. But I want to use it without using delegates and all. is there any simple way to access it like a regular textbox ??

    suchita

    S Offline
    S Offline
    Sandeep Mewara
    wrote on last edited by
    #8

    Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:

    //In UserControl.ascx.cs
    public string txtBoxInUCExposed
    {
    get { return txtBoxInUserControl.Text;}
    set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
    }

    //In Parent.aspx
    //When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"

    //In Parent.aspx.cs
    //when buttonA clicks, in its event access it as:
    string valueInUCTextBox = myUC1.txtBoxInUCExposed;
    // Now use this value to insert it in the database.

    N D 2 Replies Last reply
    0
    • N Not Active

      SayamiSuchi wrote:

      if you can't do that, better say I can't

      Don't get cocky. Look around, I think I've demonstrated ability well enough. Show what you have tried. Creating a property is very, very, very simple basic knowledge.


      I know the language. I've read a book. - _Madmatt

      D Offline
      D Offline
      Dhyanga
      wrote on last edited by
      #9

      also i am trying to use findcontrol property and its not working.. i dont know what parameter i'm missing.. my ascx page name is usercontrol.ascx and it has one textbox named textbox2. and my aspx page has one button named button1 and textbox named textbox1. now i am trying to show the value of textbox2 in textbox1 on button1 click event. protected void Button1_Click(object sender, EventArgs e) { usercontrol1 u = new usercontrol1(); string s = u.FindControl("Textbox2"); TextBox1.Text = u.ToString(); } This is not working. I doubt the way i used the textbox2 is wrong but i dont know where i'm wrong.

      suchita

      1 Reply Last reply
      0
      • S Sandeep Mewara

        Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:

        //In UserControl.ascx.cs
        public string txtBoxInUCExposed
        {
        get { return txtBoxInUserControl.Text;}
        set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
        }

        //In Parent.aspx
        //When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"

        //In Parent.aspx.cs
        //when buttonA clicks, in its event access it as:
        string valueInUCTextBox = myUC1.txtBoxInUCExposed;
        // Now use this value to insert it in the database.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #10

        My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.


        I know the language. I've read a book. - _Madmatt

        D S 2 Replies Last reply
        0
        • S Sandeep Mewara

          Hi Suchita, Based on this flow of yours: 1. Fill some value in Usercontrol ascx: ValueA 2. Press buttonA in ASPX parent page. 3. buttonA, brings ValueA in the textboxA of ASPX parent page 4. buttonA, send the ValueA in DB to store. Try this:

          //In UserControl.ascx.cs
          public string txtBoxInUCExposed
          {
          get { return txtBoxInUserControl.Text;}
          set { txtBoxInUserControl.Text = value} // as such you don't need a set based on your flow
          }

          //In Parent.aspx
          //When you drag drop the UC, you will have a UC tag in designer. Lets say you gave it an ID="myUC1"

          //In Parent.aspx.cs
          //when buttonA clicks, in its event access it as:
          string valueInUCTextBox = myUC1.txtBoxInUCExposed;
          // Now use this value to insert it in the database.

          D Offline
          D Offline
          Dhyanga
          wrote on last edited by
          #11

          Thank you to both of you..... Its a long time I didnt use dot net... So i forgot most of the part. that's the problem with me.. Slowly once again i am getting into it. thank you sandeep..

          suchita

          P 1 Reply Last reply
          0
          • N Not Active

            My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.


            I know the language. I've read a book. - _Madmatt

            D Offline
            D Offline
            Dhyanga
            wrote on last edited by
            #12

            if i take your opinion, i wont be learning ..instead i will be more frustrating... how can one learn if the confusion I have wont get out of it. I need help for that and thats what this forum is about. Dont you think so ??

            suchita

            N 1 Reply Last reply
            0
            • D Dhyanga

              if i take your opinion, i wont be learning ..instead i will be more frustrating... how can one learn if the confusion I have wont get out of it. I need help for that and thats what this forum is about. Dont you think so ??

              suchita

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #13

              I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.


              I know the language. I've read a book. - _Madmatt

              D 2 Replies Last reply
              0
              • N Not Active

                I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.


                I know the language. I've read a book. - _Madmatt

                D Offline
                D Offline
                Dhyanga
                wrote on last edited by
                #14

                i am using dot net after 4 years.so i forgot and confuse. i am restarting it again and enjoying it too. What is your problem ? If you can't help, dont post please...

                suchita

                N 1 Reply Last reply
                0
                • N Not Active

                  I've said it many times now. Creating a property is a very, very, simple basic task that you should have learned long ago. Every basic beginner book coveres it. Almost every code sample has one. If you can't figure it out, then quit, please.


                  I know the language. I've read a book. - _Madmatt

                  D Offline
                  D Offline
                  Dhyanga
                  wrote on last edited by
                  #15

                  nobody born with great mind... we need practise and guidance.. thats why we all are here in codeproject...

                  suchita

                  1 Reply Last reply
                  0
                  • D Dhyanga

                    i am using dot net after 4 years.so i forgot and confuse. i am restarting it again and enjoying it too. What is your problem ? If you can't help, dont post please...

                    suchita

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #16

                    I don't care long it has been since you last used it. Read the response again, basic simeple task covered by many, many, many, many resources. If you can't do basic tasks, then please don't bother us


                    I know the language. I've read a book. - _Madmatt

                    1 Reply Last reply
                    0
                    • D Dhyanga

                      Thank you to both of you..... Its a long time I didnt use dot net... So i forgot most of the part. that's the problem with me.. Slowly once again i am getting into it. thank you sandeep..

                      suchita

                      P Offline
                      P Offline
                      PunkIsNotDead
                      wrote on last edited by
                      #17

                      Hey what's up here? discuss your differences outside the forum ;) a property is very simple to learn! I have learned :laugh: have you searched in google?? I know nobody is perfect but when you have the opportunity to search something without posting, just search and don't mess with stressed people like us! ;) thanks :thumbsup:

                      D 1 Reply Last reply
                      0
                      • N Not Active

                        My opinion. If the OP could not have figured out how to do this simple task then giving it to him like this did not help and just made hime dependent on others and a burden to his team, now and in the future.


                        I know the language. I've read a book. - _Madmatt

                        S Offline
                        S Offline
                        Sandeep Mewara
                        wrote on last edited by
                        #18

                        Mark Nischalke wrote:

                        My opinion.

                        Got that! But out here we find lots of people asking without trying! We keep on saying, try first, show your effort. I found this OP has put effort and tried. Might be some reason(which looks like low in confidence) why OP was unable to resolve it after pointing out the way... So, to me, it looked like instead of discouraging, we should provide OP with what he is looking for. From this, he can learn what was pointed out and what was he not able to search. This will add to OP's learning curve. Not everyone can have same pace and level of understanding. One should be provided some time and help to pace up!

                        D 1 Reply Last reply
                        0
                        • P PunkIsNotDead

                          Hey what's up here? discuss your differences outside the forum ;) a property is very simple to learn! I have learned :laugh: have you searched in google?? I know nobody is perfect but when you have the opportunity to search something without posting, just search and don't mess with stressed people like us! ;) thanks :thumbsup:

                          D Offline
                          D Offline
                          Dhyanga
                          wrote on last edited by
                          #19

                          thank you...

                          suchita

                          1 Reply Last reply
                          0
                          • S Sandeep Mewara

                            Mark Nischalke wrote:

                            My opinion.

                            Got that! But out here we find lots of people asking without trying! We keep on saying, try first, show your effort. I found this OP has put effort and tried. Might be some reason(which looks like low in confidence) why OP was unable to resolve it after pointing out the way... So, to me, it looked like instead of discouraging, we should provide OP with what he is looking for. From this, he can learn what was pointed out and what was he not able to search. This will add to OP's learning curve. Not everyone can have same pace and level of understanding. One should be provided some time and help to pace up!

                            D Offline
                            D Offline
                            Dhyanga
                            wrote on last edited by
                            #20

                            Thank you all...

                            suchita

                            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