Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retreiving a value from Web User Control

Reply
Thread Tools

Retreiving a value from Web User Control

 
 
Igor
Guest
Posts: n/a
 
      06-13-2008
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

 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      06-13-2008
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(object sender, EventArgs e)
{
string House = TextBox1.Text;
}

Thanks

Munna
 
Reply With Quote
 
 
 
 
Igor
Guest
Posts: n/a
 
      06-13-2008
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"> and that form has a "nested" web
user control by <%@ Register Src="Controls/NewWebUserControl1.ascx"
TagName="WebUserControl1" 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 NewWebUserControl1) in
the code behind of the page, i.e.<form id="form1" runat="server">.

Hope its clear enough now.




"Munna" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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(object sender, EventArgs e)
> {
> string House = TextBox1.Text;
> }
>
> Thanks
>
> Munna


 
Reply With Quote
 
Mick Wilson
Guest
Posts: n/a
 
      06-13-2008
On Jun 13, 9:15*am, "Igor" <(E-Mail Removed)> wrote:
> So I have <form id="form1" runat="server"> and that form has a "nested" web
> user control by <%@ Register Src="Controls/NewWebUserControl1.ascx"
> TagName="WebUserControl1" *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 NewWebUserControl1) 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.
 
Reply With Quote
 
Igor
Guest
Posts: n/a
 
      06-13-2008
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"> and that user form has a "nested"
web
user control by <%@ Register Src="Controls/NewWebUserControl1.ascx"
TagName="WebUserControl1" 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 NewWebUserControl1) in
the code behind of the page, i.e.<form id="form1" runat="server">.




"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Igor" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-13-2008
This article should help you :

http://www.odetocode.com/articles/116.aspx

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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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"> and that user form has a "nested" web
> user control by <%@ Register Src="Controls/NewWebUserControl1.ascx"
> TagName="WebUserControl1" 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 NewWebUserControl1) in
> the code behind of the page, i.e.<form id="form1" runat="server">.
>
>
>
>
> "Mark Rae [MVP]" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> "Igor" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>>
>>> 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

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem retreiving value in javascript James Pemberton ASP .Net 4 08-17-2006 01:32 PM
Retreiving Oracle data from a custom user control in asp.net (Security errors) ElCapitan ASP .Net Building Controls 0 03-14-2006 04:18 PM
Retreiving Parent Values by specifying a attribute value pathisunil@gmail.com XML 0 05-10-2005 04:50 PM
Retreiving old value from WebControls.TextBox with OnTextChanged Mark Siffer ASP .Net 3 03-30-2005 04:38 PM
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM



Advertisments