Retreiving a value from Web User Control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Igor

    Retreiving a value from Web User Control

    Hi

    How can I reference a specific control in a web user form from web form's
    (page) code behind. In other words: I have a page (a web form) that has a
    web user form in it. I want to read a value in code behind of that page (web
    form) from a text box in the web user form.

    Kind regards

  • Munna

    #2
    Re: Retreiving a value from Web User Control

    Hi

    if html is

    <body>
    <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
    </form>
    </body>

    in code behind

    protected void Page_Load(objec t sender, EventArgs e)
    {
    string House = TextBox1.Text;
    }

    Thanks

    Munna

    Comment

    • Igor

      #3
      Re: Retreiving a value from Web User Control

      Sorry, my mistake

      How can I reference a specific control in a web user form from web form's
      (page) code behind. In other words: I have a page (a web form) that has a
      web user form in it. I want to read a value in code behind of that page (web
      form) from a text box in the web user CONTROL - not form.

      So I have <form id="form1" runat="server"a nd that form has a "nested" web
      user control by <%@ Register Src="Controls/NewWebUserContr ol1.ascx"
      TagName="WebUse rControl1" TagPrefix="uc1" %>. That WEB USER CONTROL has a
      text box <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>. How can
      I get the text value from that text box (TextBox1 in NewWebUserContr ol1) in
      the code behind of the page, i.e.<form id="form1" runat="server"> .

      Hope its clear enough now.




      "Munna" <munnaonc@gmail .comwrote in message
      news:d4d4462d-b829-4ed0-b5c2-10939f2c8a55@a1 g2000hsb.google groups.com...
      Hi
      >
      if html is
      >
      <body>
      <form id="form1" runat="server">
      <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
      </form>
      </body>
      >
      in code behind
      >
      protected void Page_Load(objec t sender, EventArgs e)
      {
      string House = TextBox1.Text;
      }
      >
      Thanks
      >
      Munna

      Comment

      • Mark Rae [MVP]

        #4
        Re: Retreiving a value from Web User Control

        "Igor" <igorm@live.com wrote in message
        news:524B7257-D350-45FF-8E25-64D2261BDD04@mi crosoft.com...
        How can I reference a specific control in a web user form
        Can you please clarify what you mean by "web user form"... Do you mean a
        UserControl...?


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • Mick Wilson

          #5
          Re: Retreiving a value from Web User Control

          On Jun 13, 9:15 am, "Igor" <ig...@live.com wrote:
          So I have <form id="form1" runat="server"a nd that form has a "nested" web
          user control by <%@ Register Src="Controls/NewWebUserContr ol1.ascx"
          TagName="WebUse rControl1"  TagPrefix="uc1" %>. That WEB USER CONTROLhas a
          text box  <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>. How can
          I get the text value from that text box (TextBox1 in NewWebUserContr ol1) in
          the code behind of the page, i.e.<form id="form1" runat="server"> .
          >
          You can access the controls collection of your nested user control
          using its ID. In your page:

          <uc:foo ID="foo" runat="server"> </uc:NotesPanel>

          In your codebehind:

          foo.FindControl ("myControl" ), or something similar.

          As an alternative, you might expose the value of your textbox as a
          Property of the user control, if it makes sense in your application.

          Comment

          • Igor

            #6
            Re: Retreiving a value from Web User Control

            Appologies once again

            How can I reference a specific control in a web user control from web form's
            (page) code behind. In other words: I have a page (a web form) that has a
            web user control in it. I want to read a value in code behind of that page
            (web
            form) from a text box in the web user control.

            So I have <form id="form1" runat="server"a nd that user form has a "nested"
            web
            user control by <%@ Register Src="Controls/NewWebUserContr ol1.ascx"
            TagName="WebUse rControl1" TagPrefix="uc1" %>. That WEB USER CONTROL has a
            text box <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>. How can
            I get the text value from that text box (TextBox1 in NewWebUserContr ol1) in
            the code behind of the page, i.e.<form id="form1" runat="server"> .




            "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message
            news:O8cgO4VzIH A.5816@TK2MSFTN GP02.phx.gbl...
            "Igor" <igorm@live.com wrote in message
            news:524B7257-D350-45FF-8E25-64D2261BDD04@mi crosoft.com...
            >
            >How can I reference a specific control in a web user form
            >
            Can you please clarify what you mean by "web user form"... Do you mean a
            UserControl...?
            >
            >
            --
            Mark Rae
            ASP.NET MVP
            http://www.markrae.net

            Comment

            • Juan T. Llibre

              #7
              Re: Retreiving a value from Web User Control

              This article should help you :



              There's several code examples of ways to find controls in it.




              Juan T. Llibre, asp.net MVP
              asp.net faq : http://asp.net.do/faq/
              foros de asp.net, en español : http://asp.net.do/foros/
              =============== =============== ========
              "Igor" <igorm@live.com wrote in message news:C5F7C3FD-A3FC-43B0-872E-A51EAE4E1B6D@mi crosoft.com...
              Appologies once again
              >
              How can I reference a specific control in a web user control from web form's
              (page) code behind. In other words: I have a page (a web form) that has a
              web user control in it. I want to read a value in code behind of that page (web form) from a text box in the web user
              control.
              >
              So I have <form id="form1" runat="server"a nd that user form has a "nested" web
              user control by <%@ Register Src="Controls/NewWebUserContr ol1.ascx"
              TagName="WebUse rControl1" TagPrefix="uc1" %>. That WEB USER CONTROL has a
              text box <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>. How can
              I get the text value from that text box (TextBox1 in NewWebUserContr ol1) in
              the code behind of the page, i.e.<form id="form1" runat="server"> .
              >
              >
              >
              >
              "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message news:O8cgO4VzIH A.5816@TK2MSFTN GP02.phx.gbl...
              >"Igor" <igorm@live.com wrote in message news:524B7257-D350-45FF-8E25-64D2261BDD04@mi crosoft.com...
              >>
              >>How can I reference a specific control in a web user form
              >>
              >Can you please clarify what you mean by "web user form"... Do you mean a UserControl...?
              >>
              >>
              >--
              >Mark Rae
              >ASP.NET MVP
              >http://www.markrae.net
              >

              Comment

              Working...