473,769 Members | 6,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control. How is this done?

Hello,

I have been trying to add a user control at runtime to a page:

Dim myUserControl As Control = LoadControl("My UserControl.asc x")

The problem is this does not give me access to the user control
properties. So I tried the following:

Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)

However MyUserControl is not recognized.

How can solve this?

I looked everywhere and I can't find the solution.

Thanks,
Miguel

Dec 15 '06 #1
5 1230
In 2.0, you need to add a @Reference directive atop your page...somethng
like:

<%@Reference Control="~/controls/user.ascx" %>

which'll then make the type available in codebehind.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@f 1g2000cwa.googl egroups.com...
Hello,

I have been trying to add a user control at runtime to a page:

Dim myUserControl As Control = LoadControl("My UserControl.asc x")

The problem is this does not give me access to the user control
properties. So I tried the following:

Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)

However MyUserControl is not recognized.

How can solve this?

I looked everywhere and I can't find the solution.

Thanks,
Miguel
Dec 15 '06 #2
Hello,

But why do I need a reference in my master page if I am doing
everything in my master page code behind code?

Thanks,
Miguel

Karl Seguin wrote:
In 2.0, you need to add a @Reference directive atop your page...somethng
like:

<%@Reference Control="~/controls/user.ascx" %>

which'll then make the type available in codebehind.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@f 1g2000cwa.googl egroups.com...
Hello,

I have been trying to add a user control at runtime to a page:

Dim myUserControl As Control = LoadControl("My UserControl.asc x")

The problem is this does not give me access to the user control
properties. So I tried the following:

Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)

However MyUserControl is not recognized.

How can solve this?

I looked everywhere and I can't find the solution.

Thanks,
Miguel
Dec 15 '06 #3
Karl,

I did add the reference and I still have the problem.
I can't access my user control properties in the code behind code of
where I add it.

Any idea?

Thanks,
Miguel

shapper wrote:
Hello,

But why do I need a reference in my master page if I am doing
everything in my master page code behind code?

Thanks,
Miguel

Karl Seguin wrote:
In 2.0, you need to add a @Reference directive atop your page...somethng
like:

<%@Reference Control="~/controls/user.ascx" %>

which'll then make the type available in codebehind.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@f 1g2000cwa.googl egroups.com...
Hello,
>
I have been trying to add a user control at runtime to a page:
>
Dim myUserControl As Control = LoadControl("My UserControl.asc x")
>
The problem is this does not give me access to the user control
properties. So I tried the following:
>
Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)
>
However MyUserControl is not recognized.
>
How can solve this?
>
I looked everywhere and I can't find the solution.
>
Thanks,
Miguel
>
Dec 15 '06 #4
The new compilation model in 2.0 makes every page+codebehind get compiled
into it's own assembly.

Just like any other assemblies, you can't use them unless they are
referenced in your project.

Since the assembly name is dynamic, you use the @reference attribute to hook
it up for it.

I don't like it, but it's how it works..

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@l 12g2000cwl.goog legroups.com...
Hello,

But why do I need a reference in my master page if I am doing
everything in my master page code behind code?

Thanks,
Miguel

Karl Seguin wrote:
>In 2.0, you need to add a @Reference directive atop your page...somethng
like:

<%@Reference Control="~/controls/user.ascx" %>

which'll then make the type available in codebehind.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******* **************@ f1g2000cwa.goog legroups.com...
Hello,

I have been trying to add a user control at runtime to a page:

Dim myUserControl As Control = LoadControl("My UserControl.asc x")

The problem is this does not give me access to the user control
properties. So I tried the following:

Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)

However MyUserControl is not recognized.

How can solve this?

I looked everywhere and I can't find the solution.

Thanks,
Miguel
Dec 15 '06 #5
Hi Karl,

I solved it using another way which I prefer.
I place all user controls inside the namespace MyWebSite.
Then I add then namespace in Web.Config.

I prefer this way. It is working ... for now :-)

Thanks,
Miguel

Karl Seguin wrote:
The new compilation model in 2.0 makes every page+codebehind get compiled
into it's own assembly.

Just like any other assemblies, you can't use them unless they are
referenced in your project.

Since the assembly name is dynamic, you use the @reference attribute to hook
it up for it.

I don't like it, but it's how it works..

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@l 12g2000cwl.goog legroups.com...
Hello,

But why do I need a reference in my master page if I am doing
everything in my master page code behind code?

Thanks,
Miguel

Karl Seguin wrote:
In 2.0, you need to add a @Reference directive atop your page...somethng
like:

<%@Reference Control="~/controls/user.ascx" %>

which'll then make the type available in codebehind.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@f 1g2000cwa.googl egroups.com...
Hello,

I have been trying to add a user control at runtime to a page:

Dim myUserControl As Control = LoadControl("My UserControl.asc x")

The problem is this does not give me access to the user control
properties. So I tried the following:

Dim myUserControl As MyUserControl =
CType(LoadContr ol("MyUserContr ol.ascx"), MyUserControl)

However MyUserControl is not recognized.

How can solve this?

I looked everywhere and I can't find the solution.

Thanks,
Miguel
Dec 15 '06 #6

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

Similar topics

1
2160
by: Barbara Alderton | last post by:
I have the following scenario: I have a user control that contains a registered menu control. The menu and other information on the user control is specific to the user accessing the site. This user control is used on many pages. In order to create this control, I need to access information in the Active Directory to create both the menu and other info displayed on the control. This access takes some time and I wanted to cache this...
6
1979
by: MattB | last post by:
I have a page header that I made as a user control (ascx) that I drop on every page in my application. The application is an eCommerce application and I have a total for items in the cart on the header. To keep this total in sync, I count the items in the cart and refresh the label text in the load event of my header control. This all works well, except for one scenario. When the user is on the "Show Cart" page, they can delete items from...
6
3380
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
4
1754
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a specific process is done,, but the form which will host the user control has to specify what has to be done Something like this , if the event is fired it should call the event in
1
318
by: Jonathan Wood | last post by:
Okay, as evidenced by other questions, I am an experienced programmer very new to ASP.NET. I have a vertical navigation bar. It is all one color with several panels inside it with a different color. It looks okay but I'm wondering if each of these several panels should be Web User Controls themselves. I think this would make sense, and I can figure out how to add a property that specifies the image that appears at the top of each of...
4
1689
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project that build a class library dll. Here we have a class called C We have one dependency and that is from the user control to the class library because in the constructor for class B in the user control we have a call to
5
1999
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something like this is a bug or that .NET doesn't support what I trying to do. I hope that one that is is microsoft certified read this because this must be a bug.
2
4823
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be required: <%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %> Assuming that the ASPX page doesn't use a code-behind, I can access the properties, events etc. of the user control in the ASPX page in this way (assume that the ASPX page...
3
2130
by: Tom | last post by:
Is there any way to 'download' a control that could access hardware on a PC? Reason is that I am considering retooling a client-server app of ours over to ASP.NET (VB.NET). However, currently that app has options that 'talk' over the serial port to a piece of hardware, controlling it and getting information to/from it. The ASP.NET app would need to do the same think. Previously, in VB6, I believe one could do something like this by...
7
2859
by: Aussie Rules | last post by:
Hi, Is there a way to have a screen/form designer functionality in a vb.net2008 program for the end user to use ? I want to be able to distribute my application, and allow the end user to make change to my forms to suit there needs, or perhaps even create there own to display certian information. Thanks
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.