473,385 Members | 1,753 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.

User Control Handle

I am trying to figure out how to get a reference to a user control in the page that is using that control

I have created several "Properties" within my UserControl that I want to access. Normally when I add a textbox to a form, when I go to my code behind page, the system generates all the code to instantiate that control. I can find no such code for a Usercontrol. I could instatiate it within my codebehind page, but I am guessing that if I do, that I will not get the handle on the one that the system instatiated some how

So how to I get the handle of that control

Thanks
Nov 18 '05 #1
2 1126
"Fred Walker" <an*******@discussions.microsoft.com> wrote in message
news:2C**********************************@microsof t.com...
I am trying to figure out how to get a reference to a user control in the page that is using that control.
I have created several "Properties" within my UserControl that I want to access. Normally when I add a textbox to a form, when I go to my code
behind page, the system generates all the code to instantiate that control.
I can find no such code for a Usercontrol. I could instatiate it within my
codebehind page, but I am guessing that if I do, that I will not get the
handle on the one that the system instatiated some how.
So how to I get the handle of that control?


Well, you don't want a handle, you want a reference.

VS.NET doesn't automatically create a class member for a user control when
you place it on a page. This just means you have to add the member on your
own:

protected MyUserControl _myUserControl;

or, in VB.NET:

Protected WithEvents _myUserControl As MyUserControl

I believe this will "just work", but I'm afraid I can't take the time to
test it right now.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
"Fred Walker" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
This does not give me the reference to class member which was instatiated.

It gives me a reference to the class, but when I attempt to use it, I get
the object not set to an instance. So how do I get the reference to the
object which was created?

Ok, first of all, there's no such thing as a reference to a class, so I
don't know what you mean by that. But if you get a NullReferenceException,
then it must not be filling in the member, which surprises me. Try filling
it with FindControl.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #3

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

Similar topics

6
by: Tom Rowton | last post by:
This one has me a bit confused and I'm not finding what I need in the MSDN or by searching these forums, so here goes... I have a rather large, complex code-in-page WebForm (don't ask) and a...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
8
by: Alan Silver | last post by:
Hello, I'm trying to write a simple user control as an exercise (and 'cos it might be useful). I am trying to do a simple date picker, which consists of three drop down lists, one for the day,...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
4
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is...
4
by: planetthoughtful | last post by:
Hi All, I have a relatively simple web user control I've included in a page that simply presents 3 drop down lists and a submit button, that I use as a date picker (ie one list for day, one for...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
5
by: rn5a | last post by:
Consider the following user control which resides in Address.ascx: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)...
1
by: Efi Merdler | last post by:
Hi, I created a user control, but instead of handling exception in the user control level I prefer to handle them in the containing form. In the load event of the containing form I'm using:...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.