DotNetNuke 模块中的自定义类
我知道这是可以做到的,因为还有其他模块也有这个功能,但我只是没有让它工作。
我为 DotNetNuke 站点创建了一个自定义模块。我希望能够在模块内创建一个类对象来保存有关该对象的信息。我可以创建对象并且一切都符合要求。但是当我在代码隐藏中使用该对象时,它指出该对象未定义。我不太确定从这里该去哪里。
这是 View.ascx.vb 的开头:
Namespace Modules.VacationForms
Public MustInherit Class View
Inherits PortalModuleBase
这是对象类的开头:
Namespace Modules.VacationForms
Public MustInherit Class Vacation
我真的不确定为什么这不起作用。我确实下载了另一个模块代码进行比较,据我所知,一切都是一样的。任何帮助表示赞赏。
I know this can be done as there are other modules out there that have this, but I'm just not getting it to work.
I have created a custom module for a DotNetNuke site. I want to be able to create a class object within the module to hold the information about that object. I can create the object and everything complies. But when I go to use the object in the code-behind it states that the object is not defined. I'm not really sure where to go from here.
This is the beginning of the View.ascx.vb :
Namespace Modules.VacationForms
Public MustInherit Class View
Inherits PortalModuleBase
This is the object class beginning:
Namespace Modules.VacationForms
Public MustInherit Class Vacation
I'm really not sure why this is not working. I did download another module code to compare and as far as I can tell everything is the same. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是网站项目还是 Web 应用程序项目? Web 应用程序项目将允许您将所有代码一起编译(这里唯一的问题可能是项目中的根命名空间设置,但是,假设两个类都在同一个项目中,则不应该是这样)。如果您处于网站项目中(例如直接在 DNN 解决方案中进行开发),那么您的代码将不会按照传统意义上进行编译,而是由 DNN 按需编译。它仅对与请求的控件/页面(例如 View.ascx.vb)关联的代码隐藏文件和 App_Code 文件夹中的代码文件执行此操作。我猜您的问题是您的
Vacation
类代码文件不在 App_Code 文件夹中。Are you using a Web Site Project or a Web Application Project? The Web Application project will allow you to compile all of your code together (the only issue here might be the the Root Namespace setting in your project, but, assuming both classes are in the same project, that shouldn't be it). If you're in the Web Site project (e.g. developing directly in the DNN solution), then your code won't get compiled in the traditional sense, but will be on-demand compiled by DNN. It only does that for code behind files associated with requested controls/pages (e.g. your View.ascx.vb) and code files in the App_Code folder. I would guess that your hangup is that your
Vacation
class' code file isn't in the App_Code folder.看来您没有使用 Web 应用程序项目进行模块开发。最简单的事情是安装模块开发模板(从 dotnetnuke.codeplex.com 下载您的 dnn 版本的 starterkit 包)。
如果您的模块太简单而您不想这样做,或者您不想在电脑上安装模板,您可以执行以下操作:
希望这有帮助
It looks you are not using the Web Application Project for module development. Easiest thing to do is install module development templates (from dotnetnuke.codeplex.com download starterkit package of your dnn version).
If your module is too simple and you don't want to do that, OR you don't want to install the templates in your pc, you can do following:
Hope this helps