Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 7th, 2003, 04:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
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).
  #2 (permalink)  
Old July 14th, 2003, 03:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I finally figured it out myself! :o) Thanks anyway.
  #3 (permalink)  
Old April 12th, 2004, 06:06 PM
Registered User
 
Join Date: Apr 2004
Location: Delhi, Delhi, India.
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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



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


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