# Registration doesn't resolve controls for "DotNetNuke.Web.UI.WebControls" - asp.net

Probably this something very simple, but I can't find what I'm doing wrong.
I want to use DNNTreeView in DNN 7.0.6 dev site. This instruction page almost get me there. The code behind resolves the controls, but the .ascx doesn't and gives me the following warning
Warning 102 Element ‘DnnTreeView’ is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing
the page looks like:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="MySpace.Modules.MyModule.View" %>
<%# Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %>
<dnn:DnnTreeView runat="server" ID="tvMain">
</dnn:DnnTreeView>
I'm using #ChrisHammond 's templates for the solution.
I have following dll references:
DotNetNuke.dll
DotNetNuke.Web.dll
Telerik.Web.UI.dll
Can you smart guys find what I'm missing?

I've found a possible solution for the "not a known element" warning. I was pulling my heart out looking for it, but I have one that works for me. All you need to do is add a bin folder to your module and put these dll's in the bin folder: DotNetNuke.dll, DotNetNuke.Web.dll, DotNetNuke.WebControls.dll, Telerik.Web.UI.dll. It doesn't matter if they are in the site bin folder, they need to be in the project bin folder, too.
I have a full explanation here

If it is just a warning, I wouldn't worry about it, that is fairly common with DNN module development using the WAP approach. If it works in DNN, then just let it go :D
You might check to make sure that you don't have a virtual directory/application on the DESKTOPMODULES folder in IIS, or on the module's folder itself.

Related

IDE says MasterPage not found, but builds/runs fine

I am stumped as to why my pages are saying the MasterPage cannot be found, even though the MasterPages are where they are specified. For example:
In default.aspx
<%# Page Title="Welcome" Language="C#" MasterPageFile="~/Master.Master"
AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="My_site.default" %>
In the above line, "~/Master.Master" is underlined in green. Hovering with my mouse shows a balloon that reads File '~/Master.Master' was not found. Master.Master definitely exists in the root folder of my site. The site builds fine and all of my pages DO find ~/Master.Master when ran on either my local PC or when uploaded to my hosting account.
The biggest annoyance is that I can't view my pages in the VS IDE because it says The Master Page file '~/Master.Master' cannot be loaded. Correct the problem in Code view. I see nothing to fix...
I have completely deleted the /obj/Debug and /obj/Development folders, clicked to Clean the entire solution, and done a complete build. Every page that uses a Master Page on my site is telling me this.
After running into some problems with long filename errors (unrelated issue) I moved my solution/project to a folder off of my C:. I named the solution folder C:\My_Site and inside of it there is a project folder called My_Site. The full path to my project files is C:\My_site\My_Site.
If I change MasterPageFile="~/Master.Master" to MasterPageFile="~/My_Site/My_Site/Master.Master" then the IDE stops reporting an error and will allow me to view pages in design mode without a problem - although the site will not build this way. The compiler reports problems that the Master Pages cannot be found.
I read a post here on SO - Error: "The file '/MasterPages/MainMaster.master' does not exist." (Yes, this file does exist!) but my files are not located in a virtual folder. I use IIS Express and so am pretty limited with configuring it. I am uneasy about right-clicking my project and converting it to anything. I'm not sure what the effect of that would be.
Anyone have an idea what's possibly happening and how I might resolve this?

Cannot Parse .aspx during WAP Conversion

I've copied over the Web Site files to a new WAP project. Made sure that it compiles and it does. The problem I have is that it can't parse the .aspx pages when I perform a convert to WAP. The error simply says it can't parse the .aspx pages.
When I look at one of the .aspx pages, I have the page directive as such but it can't recognize that namespace. That is the namespace I'm using for my new WAP project.
My code-behind pages all have the namespace Instant.Web as well as the project properties is set to Instant.Web for the primary namespace.
so when I go to a page for example, it's not recognizing the Web.Attachment portion of my Inherits.
Here's an example (slightly modified the wording for privacy):
SomeAspxPage.aspx:
<%# Page Language="C#" Inherits="Instant.Web.Attachment" Codebehind="SomeAspxPage.aspx.cs" %>
<asp:Content ID="ctlContent" ContentPlaceHolderID="ctlContentPlaceHolder" runat="Server">
<Frm:Attachment ID="Attachment1" runat="server"/>
</asp:Content>
SomeaspxPage.aspx.cs
namespace Instant.Web
{
public partial class Attachment : Instant.InstantFrm.Pages.Base.UserPage
{
}
}
Also for some reason UserPage in the code-behind isn't showing as a class that you can right-click and go to source. Not sure why because that assembly is definitely in this WAP Project and it's the latest assembly for Instant.InstantFrm
Do not know if it is relevant for your real case, but as for your example, you have an attribute Codebehind="Attachment.aspx.cs" which looks for the file Attachment.aspx.cs, but the file's name is SomeaspxPage.aspx.cs. Usually "file could not be parsed" means the wizard cannot find the matching code-behind file and cannot convert the page.
BTW one more note from here:
Before converting the project files, add references to the Web
application project for assemblies that existed in the Bin folder to
help prevent errors.
It is not clear from your description if you have added the reference to your custom UserPage. If not and that assembly is just copied somewhere into WAP Project it can also cause the converting error.
Try adding a new blank page to your project, check if that can be parsed.
Then in small steps add functionality until you get the page that is the same as the one that is giving you the error.
This should allow you to identify what the problem is.
Based on this quote Warning 126 Unrecognized tag prefix or device filter 'asp' in one of the comments, it sounds like you are missing an Assembly reference in your CSProj file.
Verify that you have System.Web in your References folder of the project.
If it is there, verify the version (directory) it is pulling from is the same as what .NET version you are targeting with your project.
Save and close the solution, then re-open it and try again.
I'm theorizing that VS is caching something and the projects needs to be reloaded.
For WAP site, I'd remove the ASPX layout completely (except the first line, which is required) and output the content using Response.Write in codebehind.
In addition to simplicity, this gives much cleaner output and granular control over the process.

Does code in aspx page get compiled in a web application?

Let me just start by saying, if anyone knows of a good article that talks about this subject, please point me towards it.
Does code in an .aspx page (in between <% %> tags) get compiled in a web application or is it treated like markup where you can just change it without recompiling the solution? Does compiling only compile the code behind code in the .cs and designer.cs files ?
If you're developing in a 'Web Application Project' (as opposed to 'Web site') then any change to class (.cs), code-behind file (.aspx.cs), designer files, etc (basically anything that isn't markup or static files like .htm) would require a rebuild in Visual Studio.
All code within a .aspx file, in or out of code blocks (<%%>) gets compiled.
Changing an .aspx file will cause IIS to recompile it on the next request.
See MSDN - ASP.NET Dynamic Compilation.
Update (following comment):
As for development work - pretty much the same happens when you use the dev web server to view the page. You do not have to recompile the solution/project, but the page will get recompiled dynamically.

Where can I put my source files?

I am developing a web form using Visual Web Developer
Currently I have class source files in the same directory as the web form, or in the App_Code folder. I'd like to organise the files into folders within the web form folder, but I can't find a way of adding a reference to the folders, and they don't seem to be being picked up automatically.
These are files that are under constant development.
What is the asp.net/c#'s equivalent concept to c++'s #include?
This is a Web Site rather than a Web Application
I'd suggest taking these out into a separate class library project and you can then reference this DLL in your web project. You would then add a 'using' statement at the top of your web form code to include this reference.
In a C# file (foo.cs), you would use:
using MyProjectsDefaultNamespace.Folder1.Folder2
In an aspx or ascx file, you would use:
<%# Import Namespace="MyProjectsDefaultNamespace.Folder1.Folder2" %>
Never really thought of doing this, but i guess i would do this as follows.
A folder represents a namespace. So where it says inherits="Project.PageName" in your PageName.aspx file, it should state inherits="Project.Folder.Folder.PageName". You also have to change the namespace in your PageName.aspx.designer.cs and PageName.aspx.cs files.
EDIT:
For ASP.Net website simply adjust your CodeFile attribute:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Folder/Folder/Default.aspx.cs" Inherits="_Default" %>
Its not clear if you mean the codebehind .aspx.cs file or a standalone .cs class file.
You can't have .cs files loose in your main folder. It has to be in the app_code folder (or in a class library if you were doing a WAP).
Your .aspx.cs files are paired up with your .aspx file. I wouldn't recommend trying to move these files away if thats what you are trying to do.
The top level namespace that contains _Default or any code that doesnt appear to have a namespace is ASP. This is generally hidden within Visual Studio. So its true name is ASP._Default
And the answer is, obtained from looking into the other answers thanks:
Organise the files into folders within the App_Code folder, they will automatically be included.
Right click on project in solution explore
Go to Add> Add ASP.NET Folder > App_Code
Then add your files/folder structure there
BUT, be warned of what you put in there. Please refer to:
http://vishaljoshi.blogspot.com/2009/07/appcode-folder-doesnt-work-with-web.html
In the properties of the source file(s), you might want to set the "Build Action" property to "Compile"

<%# MasterType TypeName="ggg.Web.Main" %>dll". Illegal characters in path

this is kinda wierd.
I have a couple projects:
ggg.Web (main WAP project)
ggg.Web.Controls (Plain C# project that holds any custom controls .cs)
When I try to compile ggg.Web.Controls, I get this error:
<%# MasterType TypeName="ggg.Web.Main" %>dll". Illegal characters in path.
It's referring to the project ggg.Web.Controls project but I've gone through every class and there is no <%# MasterType TypeName="ggg.Web.Main" %> code in any of those classes.
Only in the ggg.Web .aspx pages do I have that kind of directive specified at the top of some of my .aspx pages. ggg.Web references and uses ggg.Web.Controls.
I've tried to clean my solution, close out VS....but still nothing. This is the only error coming up during compile.
C# Web Developer
Try closing all windows, restarting Visual Studio and see if the problem persist. If it does copy/paste the error from Output pane here.
It was a corrupt project. I recreated that project, dumped back in the files and violà.

Resources