|
-
Aug 1st, 2007, 08:29 AM
#1
Thread Starter
Addicted Member
page.loadcontrol() page not found
I'm using page.loadcontrol to create an instance of a control. The problem is that it it keeps saying the page cannot be found.
Code:
Dim control As Control = page.LoadControl("/controls/OrderDetails.ascx")
I have compiled this application to one file and so there only .compiled files and a dll in the bin directory.
If i create a dummy file it tells me it has not been precompiled and so cannot be used.
Have i missed something or is there an issue with fully compiled sites?
-
Aug 1st, 2007, 11:57 AM
#2
Re: page.loadcontrol() page not found
Is the path correct? Does it work when it's in 'normal' mode (not precompiled)?
-
Aug 2nd, 2007, 04:49 AM
#3
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
Yes this code works fine when run in VS.net.
When I compile the assembly and use it within another site and call the method it throws the error.
It's clearly to do with the fact that the ASCX file does not exist in the compliled version but I would expect it to handle this in the same way it handles any other request in this situation.
Or does the loadcontrol() method demand a physical file?
If so how can I instance this control without it being there?
-
Aug 3rd, 2007, 08:05 AM
#4
Re: page.loadcontrol() page not found
Reading vague descriptions on MSDN, it does seem like the presence of the .ascx file is mandatory. However, LoadControl is overloaded and if the control is part of the project, you should be able to instantiate it by its type.
http://msdn2.microsoft.com/en-us/library/ewtd66a0.aspx
-
Aug 3rd, 2007, 08:16 AM
#5
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
Well the control works fine when you use it under the normal @Register context using the path. its just the loadcontrol method that doesn't like it.
I guess I can just make it a public type and do i that way. Will give it a go.
-
Aug 16th, 2007, 06:07 AM
#6
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
hmmm ive hit another stumbling block. not sure if it is my understanding or intellisense.....
I cant reference my user control e.g.
db.UI.UserControls.MyControl
Infact Intellisense only sees db.UI and not .UserControls or the classes.
Is there something special about a usercontrol codebhind that would prevent the namespace and class being visible to intellisense?
It wont compile either.
-
Aug 17th, 2007, 09:28 AM
#7
Re: page.loadcontrol() page not found
How've you declared the class? Is it public?
-
Aug 17th, 2007, 12:26 PM
#8
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
Yup :
vb Code:
Partial Public Class OrderDetails
Inherits System.Web.UI.UserControl
-
Aug 20th, 2007, 05:54 AM
#9
Re: page.loadcontrol() page not found
Missing namespace declaration for the class?
I know, stabbing in the dark here, but I'd have to look at the whole project to figure it out for sure, on the other hand I could tell you the most common issues...
-
Aug 20th, 2007, 04:17 PM
#10
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
i mentioned namespace in a previous post. I dont think it is that .....
db.UI.UserControls.MyControl
Intellisense only sees db.UI and not .UserControls or the classes.
-
Aug 21st, 2007, 11:02 AM
#11
Re: page.loadcontrol() page not found
I meant a namespace declaration for the class, but if you've done that, then I'm at a loss. It may be something really simple which isn't apparent to me right now.
-
Aug 21st, 2007, 12:59 PM
#12
Thread Starter
Addicted Member
Re: page.loadcontrol() page not found
But to clarify if the class is public I should be able to declare like so:
Dim ctl as myUserControl = new UserControl
or at least reference the myUserControl type?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|