473,385 Members | 2,243 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,385 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 1496
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.