usercontrol objects

N

nicholas

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!
 
G

Guest

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
 
N

nicholas

Perfect ! THX

Dan Nash said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

UserControl? 0
usercontrol - events question 2
UserControl question 1
FindControl() on ASP.NET UserControl Objects 14
UserControl 1
Default Button in a UserControl 5
CS0115 1
dynamically loading usercontrol 5

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top