2

I m very new to visual studio and dnn and I m learning the "basics" with a book. I m trying to build my very first module at the moment . In one of the ascx files I have the following code:

<%@ Control Language="C#" AutoEventWireup ="true" CodeBehind="Settings.ascx.cs" Inherits="wrox.Modules.guestbook.Settings" %>
<%@ Register TagName="label" TagPrefix="dnn" Src="~/controls/labelcontrol.ascx" %>

<fieldset>
    <div class="dnnFormItem">
        <dnn:Label ID="lblAutoApprove" runat="server" ResourceKey="lblAutoApprove"
            ControlName="chkAutoApprove" />
    </div>
</fieldset>


<asp:CheckBox runat="server" ID="chkAutoApprove" />

The following piece of code gives the following warning: file '~/controls/labelcontrol.ascx" was not found

<%@ Register TagName="label" TagPrefix="dnn" Src="~/controls/labelcontrol.ascx" %>

I need to use the labecontrol.ascx file for this piece of code.

<div class="dnnFormItem">
    <dnn:Label ID="lblAutoApprove" runat="server" 
      ResourceKey="lblAutoApprove"
        ControlName="chkAutoApprove" />
</div>

This piece of codes give the following warning because the labecontrol.ascx file is missing (As far as I know):Element 'Label' 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.

I found two simular questions on this site. The first one wasn't very helpfull because the answer was to ignore the warning. I dont want to do this. The second question wasn't helpfull either because he/she had a typo.

How can I get rid of this warning?

notes: I m using visual studio 2017 and dotnetnuke 8

B.Termeer
  • 315
  • 3
  • 18
  • I don't know if you can get rid of the warning, but you can ignore it. – Chris Hammond Mar 05 '18 at 17:08
  • IF it can be ignored, why does the warning exsists? – B.Termeer Mar 06 '18 at 07:28
  • It's because of the way the templates are setup. VS thinks they are their own IIS application, when really they will run inside of DNN. VS doesn't know where DNN is due to the format of my project templates, so it can't find the path to those files. Once running inside of DNN the files do exist and thus don't throw errors. – Chris Hammond Mar 06 '18 at 09:20
  • ahh, thanks. I still think it is a little bit odd that the warning exsists but now I understand it a little bit. – B.Termeer Mar 06 '18 at 09:27

1 Answers1

2

Its been a while since I have done DNN development but the issue is generally that when you are making a custom module, you make it with the context that the rest of DNN is there, but during develop-time, the rest of DNN is not actually there (or at least not where Visual Studio expects to find it).

I would imagine you could get rid of the warning by copying the DNN label control into the controls folder of your module. If you do this, I would make sure your build does NOT include the DNN control and that you put it in whatever ignore list your source control uses.

Jeff Martin
  • 10,812
  • 7
  • 48
  • 74