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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0referencing asx code behindreferencing asx code behind
Previous
 
Next
New Post
1/7/2007 5:04 AM
 

Hi, new to module dev and struggling understanding some differences on the asx..

Ive seen examples of 2 methods of inheriting the code behind the

first as this:

<%@ Control language="vb" Inherits="YourCompany.Modules.XContactus.XContactus" CodeFile="XContactus.ascx.vb" AutoEventWireup="false" Explicit="True" %>

the second as this :

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="XContactus.ascx.vb" Inherits="DesktopModules_XContactus_XContactus" %>

On the first i seem to get the error : Error 3 'Context' is not a member of 'YourCompany.Modules.XContactus.XContactus'. C:\dnntest\DesktopModules\XContactus\XContactus.ascx 1 1 C:\dnntest\

The second example is ok, i think i should be using the first method, but what can i be doing wrong that it compiles with the error all the time ?

Im not really sure of the mechanics in asp.net here so any help really appreciated.

br,

Andy

 
New Post
1/7/2007 12:57 PM
 

When I first add a new .ascx user control in VS2005 to my DNN module's folder, I find that the second form of the @Control directive is set up by default and in the codefile the class receives a corresponding name - in your case "DesktopModules_XContactus_XContactus.  Because I prefer to use consistent Namespace like WESNet.DNN.Modules.ModuleName.ClassName I have to manually add a Namespace statement to the Codefile, and change the class name. Corresponding changes must be made in the @Control Inherits attribute in the .ascx file.  So, I end up with:

<% @Control . . . Inherits="WESNet.DNN.Modules.EPrayer.PostPrayer" . . %>

and

Namespace WESNet.DNN.Modules.EPrayer
     Public Class PostPrayer
          Inherits PortalModuleBase

     End Class
End Namespace

In a VS2003 module project, I was able to set my root namespace and have it used automatically each time a new user control or class was added.  This seems to be missing in VS2005 unless I'm using a Web Application Project.  What am I missing?

So, it appears that either method is correct - as long as the Inherits attribute in the control matches the combination of explicit namespace and class name in the Codefile.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
1/7/2007 1:16 PM
 

Hi !

Thanks for replying, no i see the relationship between the name of the namespace + class combined = the inherits in the asx

Thanks very much.... just one last question, the examples i lookat keep referring to YourCompany.this or YourCompany.that, where do i change your Company for my company name ?

Thanks again for looking in on me ! much appreciated...

 
New Post
1/7/2007 7:52 PM
 
imagemaker wrote

Namespace WESNet.DNN.Modules.EPrayer
     Public Class PostPrayer
          Inherits PortalModuleBase

     End Class
End Namespace

Did you mean "Partial Class PostPrayer" ? Without the "Partial" that changes things a bit.



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
1/7/2007 11:39 PM
 
You're correct - I should have typed Partial Class for VB2005/ASP.Net 2.0. CodeFiles. Thanks for picking up on that.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0referencing asx code behindreferencing asx code behind


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