473,569 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you refer to a textbox that is located in a User Control?

How can I refer to MyTextBox.Text which is located in mycontrol.ascx from
within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control located on
mymainpage.aspx ).

Thanks!
Mike
Nov 17 '05 #1
10 1513
Make it a public property and you can refer to it from within container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from
within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control located on
mymainpage.aspx ).

Thanks!
Mike

Nov 17 '05 #2
Make it a public property and you can refer to it from within container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from
within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control located on
mymainpage.aspx ).

Thanks!
Mike

Nov 17 '05 #3
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?
Mike

"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within container page by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control located on mymainpage.aspx ).

Thanks!
Mike


Nov 17 '05 #4
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?
Mike

"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within container page by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control located on mymainpage.aspx ).

Thanks!
Mike


Nov 17 '05 #5
"Mike Hnatt" <do**@gladsto ne-inc.com> wrote in message
news:vp******** ****@corp.super news.com...
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?
Mike, what part didn't you understand?
--
John
"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control
located on mymainpage.aspx ).

Thanks!
Mike



Nov 17 '05 #6
"Mike Hnatt" <do**@gladsto ne-inc.com> wrote in message
news:vp******** ****@corp.super news.com...
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?
Mike, what part didn't you understand?
--
John
"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control
located on mymainpage.aspx ).

Thanks!
Mike



Nov 17 '05 #7
Thank John,

Here is what I would "think" would work:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
MyMainPageLabel .Text = "This is the first time viewing the page"
Else
MyMainPageLabel .Text = "The textbox value in the control is: " &
Mycontrol1.MyCo ntrolTextBox.Te xt
End If
End Sub

Based on a control called:
<uc1:mycontro l id="Mycontrol1 " runat="server"> </uc1:mycontrol>

Which in this user control, has a textbox:
<asp:TextBox id="MyControlTe xtBox" runat="server"> Somevalue</asp:TextBox>

I have also tried refering to it as:
mycontrol.MyCon trolTextBox.Tex t

But I get a message saying it is inaccessible because it is "protected" .

Thanks for the help!

Mike

"John Saunders" <john.saunder s at surfcontrol.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Mike Hnatt" <do**@gladsto ne-inc.com> wrote in message
news:vp******** ****@corp.super news.com...
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?

Mike, what part didn't you understand?
--
John
"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within

container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
> How can I refer to MyTextBox.Text which is located in mycontrol.ascx

from
> within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control

located
on
> mymainpage.aspx ).
>
> Thanks!
> Mike
>
>



Nov 17 '05 #8
Thank John,

Here is what I would "think" would work:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
MyMainPageLabel .Text = "This is the first time viewing the page"
Else
MyMainPageLabel .Text = "The textbox value in the control is: " &
Mycontrol1.MyCo ntrolTextBox.Te xt
End If
End Sub

Based on a control called:
<uc1:mycontro l id="Mycontrol1 " runat="server"> </uc1:mycontrol>

Which in this user control, has a textbox:
<asp:TextBox id="MyControlTe xtBox" runat="server"> Somevalue</asp:TextBox>

I have also tried refering to it as:
mycontrol.MyCon trolTextBox.Tex t

But I get a message saying it is inaccessible because it is "protected" .

Thanks for the help!

Mike

"John Saunders" <john.saunder s at surfcontrol.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Mike Hnatt" <do**@gladsto ne-inc.com> wrote in message
news:vp******** ****@corp.super news.com...
Thanks Webdiyer,
But can anyone give me a hint as to what I need to do in order to do this?

Mike, what part didn't you understand?
--
John
"Webdiyer" <yh****@21cn.co m> wrote in message
news:uw******** ******@TK2MSFTN GP10.phx.gbl...
Make it a public property and you can refer to it from within

container page
by using this property.Hope it helps,thanks!

"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
> How can I refer to MyTextBox.Text which is located in mycontrol.ascx

from
> within mymainpage.aspx ? (i.e, mycontrol.ascx is a User Control

located
on
> mymainpage.aspx ).
>
> Thanks!
> Mike
>
>



Nov 17 '05 #9
Hi,Mike,add a public property to your user control like this:

public string TextBoxText{
get{return MyControlTextBo x.Text;}
set{MyControlTe xtBox.Text=valu e;}
}

then you can use MyMainPageLabel .Text=Mycontrol 1.TextBoxText from within you
container page.Note I'm using C#!
"Mike Hnatt" <do**@gladsto ne-inc.com> дÈëÓʼþ
news:vp******** ****@corp.super news.com...
Thank John,

Here is what I would "think" would work:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
MyMainPageLabel .Text = "This is the first time viewing the page" Else
MyMainPageLabel .Text = "The textbox value in the control is: " & Mycontrol1.MyCo ntrolTextBox.Te xt
End If
End Sub

Based on a control called:
<uc1:mycontro l id="Mycontrol1 " runat="server"> </uc1:mycontrol>

Which in this user control, has a textbox:
<asp:TextBox id="MyControlTe xtBox" runat="server"> Somevalue</asp:TextBox>

I have also tried refering to it as:
mycontrol.MyCon trolTextBox.Tex t

But I get a message saying it is inaccessible because it is "protected" .

Thanks for the help!

Mike

Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4137
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One of the tabs has a subform showing order data (in datasheet view). On the same tab there is an unbound textbox (next to the datasheet). I placed a
4
1690
by: ad | last post by:
I have a string variable string sID; sID store the ID of a TextBox. I want to refer TextBox throw sID. like (TextBox which ID is sID).Text="text"; How can I do that ?
2
8377
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the...
0
340
by: Mike Hnatt | last post by:
How can I refer to MyTextBox.Text which is located in mycontrol.ascx from within mymainpage.aspx? (i.e, mycontrol.ascx is a User Control located on mymainpage.aspx). Thanks! Mike
0
1227
by: Dot net work | last post by:
Hi, Make up a very simple project as follows: 1 aspx form 3 web user controls (referred to as A, B, and C) "A" web user control: Put 1 textbox and 1 button on this web user control. (You must do this exactly!)
3
2499
by: John Mason | last post by:
Hi, I am trying to work out how to make reference to an asp textbox control within a class, contained in a user control, but receive the following error... BC30469: Reference to a non-shared member requires an object reference. Here is the code...
1
1324
by: Paul | last post by:
I have a MDI container form "frmParent". On that form there is a tabstrip control with 2 pages. On one of those pages there is a textbox and a button. When the user clicks on the button a child form is opened inside the container form "frmChild" which displays a datagrid. The WHERE clause in the select statement which is bound to the...
11
4524
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha...
0
2390
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.