473,806 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need to pass an object to a UserControl

Kym
I have an application which dynamically inserts a UserControls at run time.
When I instansiate the UserControl I need to pass it an object however I am
getting errors like...
'Value of type MyWinApp.cObjec t cannot be converted to
MyUserControl.c Object'
Can someone please let me know how to do this?

All the Best
Kym
Nov 21 '05 #1
2 1246
Kym,

In my opinion can this not be answered, if there is at least not a little
piece (and not your complete program) of the code that creates the error.

I hope this helps,

Cor
Nov 21 '05 #2
Kym,
It sounds like you have 2 projects:
= Project MyUserControl contains a UserControl and a class called cObject.
= Project MyWinApp contains your application and a class also called
cObject.

Correct?

If not, can you show what you did, with 15 or 20 lines of code?

If yes: Ah! There's the rub!!

A type is known by more then just its name MyWinApp.cObjec t is a distinct
type from MyUserControl.c Object as they are defined in different namespaces
& assemblies. A Type is known by more then just the name on the Class
statement. Its also known by the Assembly its it, plus the namespace its
explicitly or implicitly placed in. By "Assembly" I mean the name of the
assembly itself, the version of the assembly & any strong keys on the
assembly.

You only need to define the cObject type once. I would define it in the
assembly with the UserControl. In your main application you can simply
define an instance/variable of the type from the UserControl's assembly.

' MyWinApp

Private MyUserControl1 As MyUserControl.U serControl1

Dim anObject As MyUserControl.c Object

MyUserControl1. SomeProperty = anObject

Hope this helps
Jay

"Kym" <ky**@iprimus.c om.au> wrote in message
news:43******** @news.eftel.com ...
|I have an application which dynamically inserts a UserControls at run time.
| When I instansiate the UserControl I need to pass it an object however I
am
| getting errors like...
| 'Value of type MyWinApp.cObjec t cannot be converted to
| MyUserControl.c Object'
| Can someone please let me know how to do this?
|
| All the Best
| Kym
|
|
Nov 21 '05 #3

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

Similar topics

0
1863
by: Daimy | last post by:
I meet the same problem below, please help me! Thanks! //written by some one I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the
0
1185
by: ATS | last post by:
PRB: Can not get UserControl/HTML/OBJECT to work on XP/SP2/IIS/IE6 Please help, I can not get my UserControl to work from a simple OBJECT tag in a simple HTML web page on Windows XP with SP2 and IIS. I have made UserControls before, but for whatever reason, XP/SP2/IIS/something is not letting the web page run the UserControl, giving an error of "Object doesn't support this property or method". Here are the steps to reproduce:
8
6582
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable, and then I had other usercontrols simply read this by traversing the class structure: siteClass.userControlClass.specficVariable. That worked fine. The new site I'm working on is a bit different, as I'm using multiple
4
1322
by: Joe | last post by:
Hi, I am thinking about designing a website using HTML/ASP.NET. I am expecting that the website will have about 50-100 pages. I am planning on using SSI to separate the sections of the pages such as header and footer. I will have navigational menus placed on the page horizontally and vertically. I was wondering if anyone has any suggestions as how to code menus so that adding/deleting a menu item won’t mean changing each and every...
12
2933
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are gen.aspx.vb and uc.ascx.vb. With simple html or self contained vb in the user control, everything is fine and dandy. So the next stage is to pass back a simple variable from the user control to the host page. I used VS.NEt to create the files.
0
1384
by: cjbland | last post by:
This one has me stumped and I've spent countless hours trying to find a solution. I have a UserControl being called from my main .aspx page. main-page.aspx: <%@ Register TagPrefix="my" TagName="control" Src="~/tmpcontrol.ascx" %> .... <my:control id="my-control1" runat="server" SomeVal="TestString" /> ....
1
8372
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an instance of an object.'" I've traced the problem to a custom control I created that inherits from Inherits System.Windows.Forms.TextBox. In this custom control, I have two constructors. I'm not sure why I created the second constructor -- it was so...
3
2141
by: Ronald S. Cook | last post by:
I want to something as simple as: UserControl uctTemp; But the type will be passed in to the function (which will be an existing user control like "uctMyUserControl1") So, how can I pass in the string "uctMyUserControl1" and then somehow dim an instance of it?
1
13883
by: moondaddy | last post by:
I have a c# 3.5 wpf app which uses user controls for data entry screens. These data entry screens can be nested inside of each. We can also have several ones open side by side at the same time. All are in a single window. My challenge is to know when a data entry screen (UC) becomes the active control, and when the active user control looses focus and when the next one gets the focus, and so on. When a user control gets or looses...
0
9719
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
10618
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10371
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
10110
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...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.