p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Dynamic Usercontrol Issue (http://p2p.wrox.com/showthread.php?t=43407)

~Bean~ June 2nd, 2006 01:05 PM

Dynamic Usercontrol Issue
 
I am migrating a site to 2.0 from 1.1. In the old pages I have a usercontrol that I load dynamically but I am getting an error:

"Type 'recnav' is not defined"

in my Declaration:

Protected RecNav As recnav

Where recnav is my usercontrol saved as recnav.ascx.

This worked before...is there something I have to do differently in 2.0?

-------------------------
Beware of programmers with screwdrivers...

Imar June 2nd, 2006 05:38 PM

Hi Bean,

You need to add a reference to the markup of your page, so the code behind knows what control you're talking about. You can either set the Control property to the user control or the VirtualPath property. Here's a quick example:

<%@ Reference Control="~/Controls/AdminMenu.ascx" %>

Then in your code behind, you can new up an instance of AdminMenu (in this example)

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

~Bean~ June 5th, 2006 01:35 PM

Thanks yes that worked, I also declared the usercontrol like so:

Protected RecNav As ASP.MyControlName

-------------------------
Beware of programmers with screwdrivers...


All times are GMT -4. The time now is 01:27 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.