Dnn module development steps

Source: Internet
Author: User
Tags dnn
I recently started to learn dnn. The first task I received was to develop the dnn module. Recently, a friend asked me about the development process. I want to write it on a blog. On the one hand, I want to share resources and on the other hand, I hope I can get advice from dnn developers.

In terms of module development, I used the following solutions:
The interface layer and code layer are completely separated.

It is not accidental for me to adopt this solution because I have never done ASP or Asp.net development before, so I am not interested in the interface presentation layer of Asp.net. So I put the Execution Code of the module into another project. However, this still benefits from the Asp.net framework. If it is under ASP, this development mode is impossible.

Because of my poor writing skills, you can use QQ, MSN, or email to communicate clearly.

First, open the project template and create a dnn site (figure 1). As I demonstrate a dnn site that has been created, an additional toptopmodules folder is added, this folder does not exist when you first create a site. This folder is used to store the dnn module folder.

Figure 1

Then, add the dnn module through the Project Wizard. Here, I chose C #, because I personally prefer C #. Here I create a request module. Figure 2

Figure 2

After the module is added, change the name of the folder where the module is located to the module name, and change modulename to request. Figure 3

Figure 3

The addition of a module is complete, but if you want to put the Execution Code of the module into another project, we need to do some work.

Here, I create another class library project called hgg. Request. The name is only for project management and technically meaningless. Figure 4 and figure 5 show two screenshots.

Figure 4


Figure 5

You can find that the CS file corresponding to each page is moved to the hgg. Request project, and the data processing file is also moved to this project.

How are these two projects associated? Take the editrequest. aspx file as an example. When this file was initially generated by the Project Wizard, the Code is as follows:
<% @ Control Language = "C #" inherits = "yourcompany. modules. Request. editrequest" codefile = "editrequest. ascx. cs" autoeventwireup = "true" %>

When I put the Execution Code in the hgg. Request project, I must make the following adjustments to the above Code:
<% @ Control Language = "C #" inherits = "hgg. modules. Request. editrequest" autoeventwireup = "false"
Explicit = "true" %>

The most critical change is that codefile settings are deleted and inherits settings are modified. In short, hgg. modules. request. editrequest is in hgg. processing editrequest in the request project. aspx class. The class name is editrequest and the namespace is hgg. modules. request.

After completing the above step, we basically completed the separation of the presentation layer and the code layer. The following question is how the two layers can communicate.

In this regard, Asp.net is doing very well and there is dynamic event binding on the. NET Framework. Such technology is equally effective in Asp.net.

For example, there is a button on request. aspx:
<Div style = "float: Left;">
<Asp: linkbutton id = "previuslink" runat = "server" text = "previous" cssclass = "normal"/>
</Div>
If we want to handle the event after it is clicked, we need to do the following in the request. CS file of the hgg. Request project:
1. Define event binding during page loading:
// Declare event binding
Private void registerevents ()
{
Searchbutton. Click + = new eventhandler (searchbutton_click );
Previuslink. Click + = new eventhandler (previouslink_click );
Nextlink. Click + = new eventhandler (nextlink_click );
This. Load + = new eventhandler (editrequest_load );
}
// Define the event processing code
Private void previuslink_click (Object sender, eventargs E)
{
Movepage (segmentdata, false );
}

Here, previuslink is an attribute in this class. I use this attribute to obtain the request. previuslink reference on Aspx. Here, hgg. the request class in the request is similar to the request on the dnn website. aspx is connected. How is this attribute defined? The following is its code:
Private linkbutton previuslink
{
Get
{
Return (linkbutton) findcontrol ("previuslink ");
}
}
This is the key.

I don't want to talk about anything else here. the development mode of Windows class libraries is almost the same.

Now, this article is over. I hope you can make it clear.
(Recently I am also studying dnn skin)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.