Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedCode-behind does not work in my new DNN module.Code-behind does not work in my new DNN module.
Previous
 
Next
New Post
9/22/2016 4:45 PM
 

I have created my first DotNetNuke7 C# Compiled Module project in Visual Studio, and its client-side (view.ascx) works fine, but I can't get code-behind (view.ascx.cs) to execute.

I have defined ASP:button, and onclick event for it, and VS itsself created corresponding method in code-behind. It compiled well, but when I try to access application through browser, I get error message

Error: DNN_IJPP is currently unavailable.DotNetNuke.Services.Exceptions.ModuleLoadException: c:\websites\dnndev.me\DesktopModules\DNN_IJPP\DNN_IJPP\View.ascx(113): error CS1061: 'ASP.desktopmodules_dnn_ijpp_view_ascx' does not contain a definition for 'Unnamed_Click'...

which surely exists in code-behind :

 

protected void Unnamed_Click(object sender, EventArgs e)
{ Console.WriteLine("postback!");}

When I change Unnamed_Click to Page_Load (which is generated in first version of ascx.cs file), error dissapears. So I think that code-behind file does not even get compiled into dll, and that its old version stands in there. In my csproj file it's written

    <Compile Include="View.ascx.cs">

      <DependentUpon>View.ascx</DependentUpon>

      <SubType>ASPXCodeBehind</SubType>

    </Compile>

so I really do not understand what is going on here. How can I diagnose it ?

 
New Post
9/26/2016 9:06 PM
 
You should make sure that if you made any class name or namespace changes, they're also reflected in the ASCX file. Also, you'll need to rebuild after you make that change before the server-side method is known to the ASCX file.

Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
10/31/2016 4:32 AM
 

What Will said is absolutely true, but the devil is in the details.  I remember having this issue when I first started--it's most definitely the fact that the compiler cannot 'see' the ascx file because the namespace for either your project, or the code-behind does not match the info in the first line of you ascx file.

For instance:

Let's say you have a view.ascx file with a namespace like this:

Namespace DotNetParts.ModuleName

Partial Class ViewModuleName Inherits Entities.Modules.PortalModuleBase

And you ascx file (1st line) looks like:

Codebehind="ViewModuleName.ascx.vb" Inherits="DotNetParts.ModuleName.ViewModuleName" 

I realize this is in vb, but the same rules apply.  The above code behind matches the view file name, and the inherits includes the full namespace path to the control.

Now, if the project properties library name does not match 'DotNetParts.ModuleName', you will have an issue. For instance, if your library name is just 'JoeModule', I *think* (it's been a while) that it will try to assemble a namespace path as  JoeModule.DotNetParts.ModuleName (I forget which, but you get the point, right?), and it will never find the ascx file. 

I won't confuse you by getting into add'l issues you would have in a vb environment, since you're strictly asking about c#.  Also make sure the Assembly Name (the name of the dll that is created on compile) matches the Root Namespace.  So in the above example, you would have DotNetParts.ModuleName in both the Assembly Name field and the Root Namespace field.

Once of the ways I have found to diagnose these issues is to use intellisense.  Find a new line and try to type out the whole path to your class.  You can usually discover what VS *thinks* the path is to the class by seeing what intellisense is doing.  For instance, in the above example, start with the info in the Root Namespace field.  Type that out, and see what is hanging off the end of it...

Hope this helps.  I know that can be really frustrating when you're just starting out...

 
New Post
10/31/2016 4:40 AM
 

In reading through your explanation again, I'm not sure this is a namespace issue.  You do not say where Unnamed_Click is defined, so it's impossible to see what could be wrong.  Where is the definition for this event?  If you're using c# and you don't specify autowire events, you have to define each event you want to process.  And irregardless, the unnamed click event has to be an event for some *control*.  What is the name of that control and where are the events defined for that control?  We need more info than this to help.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedCode-behind does not work in my new DNN module.Code-behind does not work in my new DNN module.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out