473,387 Members | 1,318 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,387 software developers and data experts.

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.cObject cannot be converted to
MyUserControl.cObject'
Can someone please let me know how to do this?

All the Best
Kym
Nov 21 '05 #1
2 1229
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.cObject is a distinct
type from MyUserControl.cObject 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.UserControl1

Dim anObject As MyUserControl.cObject

MyUserControl1.SomeProperty = anObject

Hope this helps
Jay

"Kym" <ky**@iprimus.com.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.cObject cannot be converted to
| MyUserControl.cObject'
| 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
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...
0
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...
8
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,...
4
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...
12
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...
0
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"...
1
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...
3
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...
1
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. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.