Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cannot find type of user control?

Reply
Thread Tools

Cannot find type of user control?

 
 
Jacob Avlund
Guest
Posts: n/a
 
      09-23-2004
Hello all,

I wish to load two user controls (cart.ascx and products.ascx)
programatically.

What I'm doing right now:

In my aspx file, two references are added:

<%@ Reference Control="./products.ascx" %>
<%@ Reference Control="./cart.ascx" %>

In the ascx files, I have added a corresponding classname:

<%@ Control Language="C#" classname="Products" src="duplicate.ascx.cs"
Inherits="Duplicate.Products" %>
<%@ Control Language="C#" classname="Cart" src="duplicate.ascx.cs"
Inherits="Duplicate.Cart" %>

Here comes the problem now. I've put this code in my aspx.cs file:

Control productsControl = LoadControl( "./products.ascx" );
Control cartControl = LoadControl( "./cart.ascx" );
if( productsControl != null )
( (Products)productsControl ).listPurchases += new
ListPurchasesEventHandler( ( (Cart)cartControl ).listPurchases );
Page.Controls.Add( productsControl );
Page.Controls.Add( cartControl );

It simply refuses to cast to (Products) and (Cart) at line 4. The problem
being that the compiler apparently does not know the type.

I've tried for days to get it working. All files are in the root directory
and the same namespace. If I compile the ascx files to a dll file, it
apparently works - but I see no apparent reason why it shouldn't work the
other way?

Please help... all suggestions are very welcome.

Best regards and thanks in advance,

J.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 3 02-14-2011 05:28 AM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
Cannot upgrade Google Earth cannot find {18D3ED9E-183C-4C00-B333-FB0C2FAE8B0F} joewo Computer Support 3 10-09-2007 05:23 AM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM
Browser cannot find any server anymore after 5 minutes of normal activity (" The page cannot be displayed ") reply@newsgroup.please Computer Support 6 01-05-2004 04:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57