View the source code and understand the dnn Module

Source: Internet
Author: User
Tags dnn

Q:

 

I have created multiple user controls in vs2010, which represent multiple functions. For example, there are two controls under news management, including adding news and news lists. Now I am in dnn

Creates a newsmanager module. Create two pages in dnn: newsadd. aspx and newslist. aspx, and add them to newsmanager respectively,

My question is: why does the newsmanager module only display one of the newsadd. ascx controls and cannot display different controls on two pages?

Create a module?

A:

To solve this problem, you must first correctly understand how modules in dnn work.

Since it is open-source software, you have to learn how to look at open-source software.CodeSolve your problem. Here, I use the HTML module that every dnn will bring to answer your questions by analogy.

The HTML module consists of two functions: "edit content" and "my work". The following is an example:

Edit content

Addnews

My work

Listnews

First, you do not need two pages to display addnews and listnews respectively. You only need to load addnews or listnews on one page.

You can first see how html loads the two modules in a page.

Edit content

Http: // localhost: 91/home/Tabid/56/CTL/edit/Mid/365/default. aspx? Popup = true

My work

Http: // localhost: 91/home/Tabid/56/CTL/mywork/Mid/365/default. aspx? Popup = true

You can see that most of the things in the URL are the same, but the only difference is that the CTL value is different, namely CTL = edit and CTL = mywork.

This is how dnn is used to determine which module to load. Where is this value specified? This is actually specified in the. dnn file. You can check it in a simple way.

Go to host-> extensions and click the pen next to the HTML module to enter the editing status. You can find the module definition section. You can see the module control section.

You can see that the three control. Control IDs are, edit, mywork, and settings.

How to call these controls, we open the HTML module'sSource codeFind the "htmlmodule. ascx. cs" file. Find the moduleactioncollection property.

Find the two parts:

 
1:// Add the edit text action
 
2:VaR actions =NewModuleactioncollection ();
 
3:Actions. Add (getnextactionid (),
4:Localization. getstring (moduleactiontype. addcontent, localresourcefile ),
 
5:Moduleactiontype. addcontent,
 
6:"",
 
7:"",
 
8:Editurl (),
 
9:False,
 
10:Securityaccesslevel. Edit,
 
11:True,
12:False);
 
1:// Add mywork to Action menu
 
2:Actions. Add (getnextactionid (),
3:Localization. getstring ("Mywork. Action", Localresourcefile ),
 
4:"Mywork. Action",
 
5:"",
 
6:"View.gif",
 
7:Editurl ("Mywork"),
 
8:False,
 
9:Securityaccesslevel. Edit,
10:True,
 
11:False);

Pay attention to the two identified functions, which will generate the corresponding two URLs. You may ask what is the first function that does not need to pass parameters? If you want to know the answer, you can check the source code of the function.

Editurl ()

Http: // localhost: 91/home/Tabid/56/CTL/edit/Mid/365/default. aspx? Popup = true

Editurl ("mywork ")

Http: // localhost: 91/home/Tabid/56/CTL/mywork/Mid/365/default. aspx? Popup = true

Here, you should be able to get a general idea of how the dnn module combines various controls and loads them?

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.