473,398 Members | 2,212 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,398 software developers and data experts.

Help: Simple user control

I create a simple user control and exposed a property, "MyProperty".

I dragged it onto a new webform. I want to access the exposed property
("MyProperty") of the user control. But, I cannot access the user control.
The (ID) property of the user control is set to "ucFilter", but trying to
access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter' is not
declared.)

Any ideas? Thanks.
Nov 18 '05 #1
5 1049
in code behind declare a corresponding instance
so if your control looks something like this in design view
<UCFilter:UCFilter1 runat=server></UCFilter>

then go into your code behind and add

protected UCFilter UCFilter1;

after you have added this you should be able to access the property using
UCFilter1.MyProperty

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
I create a simple user control and exposed a property, "MyProperty".

I dragged it onto a new webform. I want to access the exposed property
("MyProperty") of the user control. But, I cannot access the user
control.
The (ID) property of the user control is set to "ucFilter", but trying to
access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter' is
not
declared.)

Any ideas? Thanks.

Nov 18 '05 #2
I tried that but I keep getting this error: System.NullReferenceException:
Object reference not set to an instance of an object.

Here's what I did:
In my design view it looks like this:
<%@ Register TagPrefix="uc1" TagName="ucFilter" Src="ucFilter.ascx" %>
:
<uc1:ucfilter id="UcFilter1" runat="server"></uc1:ucfilter>

In my code behind:
Protected MyFilter As ucFilter
:
Response.Write(MyFilter.RegionalMgr) ' ERROR OCCURS!

Any ideas?

Thanks!
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
in code behind declare a corresponding instance
so if your control looks something like this in design view
<UCFilter:UCFilter1 runat=server></UCFilter>

then go into your code behind and add

protected UCFilter UCFilter1;

after you have added this you should be able to access the property using
UCFilter1.MyProperty

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
I create a simple user control and exposed a property, "MyProperty".

I dragged it onto a new webform. I want to access the exposed property
("MyProperty") of the user control. But, I cannot access the user
control.
The (ID) property of the user control is set to "ucFilter", but trying to access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter' is
not
declared.)

Any ideas? Thanks.


Nov 18 '05 #3
Protected UcFilter1 as UcFilter

Response.Write(UcFilter1.RegionalMgr)

you need to decalre your variable as the ID you give your in design view

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
I tried that but I keep getting this error: System.NullReferenceException: Object reference not set to an instance of an object.

Here's what I did:
In my design view it looks like this:
<%@ Register TagPrefix="uc1" TagName="ucFilter" Src="ucFilter.ascx" %>
:
<uc1:ucfilter id="UcFilter1" runat="server"></uc1:ucfilter>

In my code behind:
Protected MyFilter As ucFilter
:
Response.Write(MyFilter.RegionalMgr) ' ERROR OCCURS!

Any ideas?

Thanks!
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
in code behind declare a corresponding instance
so if your control looks something like this in design view
<UCFilter:UCFilter1 runat=server></UCFilter>

then go into your code behind and add

protected UCFilter UCFilter1;

after you have added this you should be able to access the property using
UCFilter1.MyProperty

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
I create a simple user control and exposed a property, "MyProperty".

I dragged it onto a new webform. I want to access the exposed property ("MyProperty") of the user control. But, I cannot access the user
control.
The (ID) property of the user control is set to "ucFilter", but trying

to access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter' is not
declared.)

Any ideas? Thanks.



Nov 18 '05 #4
As Hermit was saying, your ID property "UcFilter1" should be the same as the
object name.

Instead of:
Protected MyFilter As ucFilter
Try
Protected UcFilter1 As ucFilter

Then use the name UcFilter throughout your codebehind.

HTH,

bill

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
I tried that but I keep getting this error: System.NullReferenceException: Object reference not set to an instance of an object.

Here's what I did:
In my design view it looks like this:
<%@ Register TagPrefix="uc1" TagName="ucFilter" Src="ucFilter.ascx" %>
:
<uc1:ucfilter id="UcFilter1" runat="server"></uc1:ucfilter>

In my code behind:
Protected MyFilter As ucFilter
:
Response.Write(MyFilter.RegionalMgr) ' ERROR OCCURS!

Any ideas?

Thanks!
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
in code behind declare a corresponding instance
so if your control looks something like this in design view
<UCFilter:UCFilter1 runat=server></UCFilter>

then go into your code behind and add

protected UCFilter UCFilter1;

after you have added this you should be able to access the property using
UCFilter1.MyProperty

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
I create a simple user control and exposed a property, "MyProperty".

I dragged it onto a new webform. I want to access the exposed property ("MyProperty") of the user control. But, I cannot access the user
control.
The (ID) property of the user control is set to "ucFilter", but trying

to access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter' is not
declared.)

Any ideas? Thanks.



Nov 18 '05 #5
That was it! Thanks everyone!!!!!

"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
As Hermit was saying, your ID property "UcFilter1" should be the same as the object name.

Instead of:
Protected MyFilter As ucFilter
Try
Protected UcFilter1 As ucFilter

Then use the name UcFilter throughout your codebehind.

HTH,

bill

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
I tried that but I keep getting this error:

System.NullReferenceException:
Object reference not set to an instance of an object.

Here's what I did:
In my design view it looks like this:
<%@ Register TagPrefix="uc1" TagName="ucFilter" Src="ucFilter.ascx" %>
:
<uc1:ucfilter id="UcFilter1" runat="server"></uc1:ucfilter>

In my code behind:
Protected MyFilter As ucFilter
:
Response.Write(MyFilter.RegionalMgr) ' ERROR OCCURS!

Any ideas?

Thanks!
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message news:Of**************@TK2MSFTNGP14.phx.gbl...
in code behind declare a corresponding instance
so if your control looks something like this in design view
<UCFilter:UCFilter1 runat=server></UCFilter>

then go into your code behind and add

protected UCFilter UCFilter1;

after you have added this you should be able to access the property using UCFilter1.MyProperty

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
>I create a simple user control and exposed a property, "MyProperty".
>
> I dragged it onto a new webform. I want to access the exposed property > ("MyProperty") of the user control. But, I cannot access the user
> control.
> The (ID) property of the user control is set to "ucFilter", but
trying to
> access "ucFilter.MyProperty" doesn't work. (It says that 'ucFilter'

is > not
> declared.)
>
> Any ideas? Thanks.
>
>



Nov 18 '05 #6

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

Similar topics

4
by: Scott C. Reynolds | last post by:
Hi. I have created a templated control, and I want to know how i can set it up so that the projects consuming it will have all the same intellisense benefits of using any other server control. ...
8
by: Tim Geiges | last post by:
Since I am being challenged with learning c# I figured I could pass some of the pain on to you guys :-) I have another question(this one is important for me to fix before I can get my app to Beta)...
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...
2
by: tperri | last post by:
I've got a page with a couple ascx files on it. One od the controls displays a user's picture, the other contains a datagrid where a user can upload more pictures, change their default picture,...
1
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add...
5
by: serge calderara | last post by:
Dear all, I try to study Web user control .For that I have created a simple text box with button as a webuser control which has 2 properties. Then I drop my user control on a web page for...
1
by: serge calderara | last post by:
Dear all, I have created a simple user control (server Button) with a public property define has follow: Public Property value() As Integer Get 'return value Return ViewState("Value") End...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
3
by: Robert Dufour | last post by:
I am trying to localize a very simple web site (english and french) I have a master page and one content page for now. On the master page I have placed a Localize control On the content page I...
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: 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
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
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...
0
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
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...

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.