Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2003, 04:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loading user control dynamically from code-behind


I am trying to put as much code in code-behind as possible, thus reducing the size of my .aspx file. I relation to this I have put the Page_Load method in a .cs file and inherited Page.

However this causes some problems. Before moving the Page_load method I was able to do something like this...

Code:
main_ascx obj001 = (main_ascx) Page.LoadControl("controls/main.ascx");
and using this directive to register the user control...

Code:
<%@ Register TagPrefix="OCMS" TagName="View" src="controls/main.ascx" %>
I do not know how to do the registration of the user control in code-behind. I have tried to use the first piece of code in the code-behind, and leaving the regisrtation in the .aspx file, however this does not work. I get this...

Code:
OCMScore.cs(14,5): error CS0246: The type or namespace name 'main_ascx' could not be found (are you missing a using directive or an assembly reference?)
How can I make a using directive or an assembly reference in code-behind when I have got no namespace!? Or do I have a namespace?

Thanks

Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old July 14th, 2003, 03:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I finally figured it out myself! :o) Thanks anyway.
 
Old April 12th, 2004, 06:06 PM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to praveen_bis
Default

Hi Jacob,
I am new to ASP.NET and am facing a similar problem in calling a user control in code behind. Can you please help me in solving the problem.

Regards,
Praveen






Similar Threads
Thread Thread Starter Forum Replies Last Post
user control code chroniclemaster1 ASP.NET 2.0 Professional 11 September 25th, 2008 03:53 PM
loading user control with callback scripts in a cu brijrajsingh ASP.NET 2.0 Professional 0 March 10th, 2007 04:14 AM
Problem with loading user control multiple times neha mukerjee ASP.NET 2.0 Basics 0 February 24th, 2006 06:11 AM
User Control / Code-behind ViagraFalls ASP.NET 1.0 and 1.1 Basics 3 November 1st, 2003 09:18 PM





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