473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1491
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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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**@gladstone-inc.com> wrote in message
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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**@gladstone-inc.com> wrote in message
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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.EventArgs) 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.MyControlTextBox.Text
End If
End Sub

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

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

I have also tried refering to it as:
mycontrol.MyControlTextBox.Text

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

Thanks for the help!

Mike

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Mike Hnatt" <do**@gladstone-inc.com> wrote in message
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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.EventArgs) 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.MyControlTextBox.Text
End If
End Sub

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

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

I have also tried refering to it as:
mycontrol.MyControlTextBox.Text

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

Thanks for the help!

Mike

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Mike Hnatt" <do**@gladstone-inc.com> wrote in message
news:vp************@corp.supernews.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.com> wrote in message
news:uw**************@TK2MSFTNGP10.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**@gladstone-inc.com> дÈëÓʼþ
news:vp************@corp.supernews.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 MyControlTextBox.Text;}
set{MyControlTextBox.Text=value;}
}

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

Here is what I would "think" would work:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.MyControlTextBox.Text
End If
End Sub

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

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

I have also tried refering to it as:
mycontrol.MyControlTextBox.Text

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

Thanks for the help!

Mike

Nov 17 '05 #10
Perfect, thanks a lot. It worked! PS, I had to remember to add the line:
Protected WithEvents Searchcontrol1 As myproject.mycontrol

Mike

"Webdiyer" <yh****@21cn.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hi,Mike,add a public property to your user control like this:

public string TextBoxText{
get{return MyControlTextBox.Text;}
set{MyControlTextBox.Text=value;}
}

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

Here is what I would "think" would work:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.MyControlTextBox.Text
End If
End Sub

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

Which in this user control, has a textbox:
<asp:TextBox id="MyControlTextBox"

runat="server">Somevalue</asp:TextBox>
I have also tried refering to it as:
mycontrol.MyControlTextBox.Text

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

Thanks for the help!

Mike


Nov 17 '05 #11

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

Similar topics

3
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...
4
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
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...
0
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
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...
3
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...
1
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...
11
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.