473,513 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

usercontrol objects

I have an aspx page.
On that page there is a user control (ascx-file) that contains user-login
info.

How can I access variables defined on the ascx-page (usercontrol) from
within my aspx-page.

I tried for ex. to put a textbox (MyTextBox) in the user control.
But when, on my aspx-page I try to get the value of that textbox
(MyTextBox.text) I get an error that says that MyTextBox is not defined.

THX for helping me!
Nov 18 '05 #1
2 855
Hi Nicholas,

I've never actually accessed controls directly, but when accessing a
control/variable in a user control, you have to reference the control first...

yourcontrol1.MyTextBox.Text

If this is happening in the Code-Behind, you also need to add a reference to
your user control in the code-behind

private YourControl yourcontol1;

where YourControl is the TagName in your Register directive, and
yourcontrol1 is the ID of the instance of the control you created.

I hope this helps! Any probs post back.

Cheers
dhnriverside

"nicholas" wrote:
I have an aspx page.
On that page there is a user control (ascx-file) that contains user-login
info.

How can I access variables defined on the ascx-page (usercontrol) from
within my aspx-page.

I tried for ex. to put a textbox (MyTextBox) in the user control.
But when, on my aspx-page I try to get the value of that textbox
(MyTextBox.text) I get an error that says that MyTextBox is not defined.

THX for helping me!

Nov 18 '05 #2
Perfect ! THX

"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:8D**********************************@microsof t.com...
Hi Nicholas,

I've never actually accessed controls directly, but when accessing a
control/variable in a user control, you have to reference the control first...
yourcontrol1.MyTextBox.Text

If this is happening in the Code-Behind, you also need to add a reference to your user control in the code-behind

private YourControl yourcontol1;

where YourControl is the TagName in your Register directive, and
yourcontrol1 is the ID of the instance of the control you created.

I hope this helps! Any probs post back.

Cheers
dhnriverside

"nicholas" wrote:
I have an aspx page.
On that page there is a user control (ascx-file) that contains user-login info.

How can I access variables defined on the ascx-page (usercontrol) from
within my aspx-page.

I tried for ex. to put a textbox (MyTextBox) in the user control.
But when, on my aspx-page I try to get the value of that textbox
(MyTextBox.text) I get an error that says that MyTextBox is not defined.

THX for helping me!

Nov 18 '05 #3

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

Similar topics

3
3158
by: Dave McCracken | last post by:
I am hosting .Net UserControls in HTML pages with Object Tags. These UserControls are clients of remotable objects that run on the same machine. The remote objects execute callbacks via sponsor...
1
3669
by: bob scola | last post by:
I have a csharp, VS 2003 solution for a winform application The application uses an object called a "matter" and the class is defined in matter.cs. I can load matter objects into a combobox ...
3
3948
by: ZhangZQ | last post by:
Supposing I have a class "UserControl1 : System.Windows.Forms.UserControl" in an Assembly "UI.dll", now I create an Application project and want to use the "UserControl1" in another AppDomain, ...
5
511
by: Dave McCracken | last post by:
I am hosting .Net UserControls in HTML pages with Object Tags. These UserControls are clients of remotable objects that run on the same machine. The remote objects execute callbacks via sponsor...
3
3023
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message">...
0
7264
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
7166
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...
0
7386
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
7543
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...
1
7106
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...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5689
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,...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.