Implementation of. net cms: The first article "discussion-code comparison"

Source: Internet
Author: User

The code in this article is C #
I have seen many CMS systems, and they are incredibly powerful and admirable. However, if there are gains or losses, the functions may not be good. After all, they cannot be used.
Furthermore, after all, it is developed by others, which limits development.
I was so itchy that I wanted to write a. NET-based CMS.
No more nonsense.
 
Let's talk about binding data first.
There are multiple data binding methods.
① Use server controls
Note: Drag controls are the biggest reason for the Master's contempt for. net. There are many drawbacks, resulting in a lot of junk code, which has a great impact on the layout of the web page and cannot make beautiful pages.
Therefore, it is not described here.
② Direct loop output html
Example:
<Div>
<Ul>
<%
String strWhere = ""; // Condition
Int currentPage = 1; // current page
If (Request. QueryString ["PageNum"]! = Null)
{
If (v. IsInteger (Request. QueryString ["PageNum"]. ToString () = "") // you can determine whether the value is a number.
{
CurrentPage = int. Parse (Request. QueryString ["PageNum"]. ToString ());
}
}
Int showCounts = 15; // The number of rows displayed on the page is www.2cto.com.
String strOrder = "order by [CreateDateTime] DESC"; // sorting rule
List <News> list_News = newsDao. GetAllNews (currentPage, showCounts, strWhere, strOrder); // obtain News data
Pager p = newsDao. GetAllNewsPager (currentPage, showCounts, strWhere); // obtain paging data
%>
<% Foreach (News n in list_News) %>
<% {%>
<Li> <span> <% = n. CreateDateTime %> </span> <a href = "Detail. aspx? NID = <% = n. NID %> "> <% = n. NewsTitle %> </a> </li>
<% }%>
</Ul>
</Div>
<Div>
<Span class = "pager"> <% = Method. PagerInfo ("current", p) %> </span> <! -- Page number -->
</Div>

The above is a simple example. You may write differently, but the principles are similar.
After encapsulation, the following result is obtained:
<Div>
<Ul>
<% TblName = "News"; Filed = "NewsID, Title, Time"; Num = 15; Sort = "[Time] DESC"; Page = true; %>
<% = Aspx (@"
<Li> <span> {2} </span> <a href = 'detail. aspx? NID = {0} '> {1} </a> </li>
") %>
</Ul>
</Div>
<Div>
<Span class = "pager"> <% = AspxP ("current") %> </span> <! -- Page number -->
</Div>

See if it is much simpler. In addition, you can use the custom "Aspx" function to cover all lists and fields. Paging is implemented through "AspxP.
And more flexible. TblName indicates the table name, Filed indicates the field, Num indicates the number of items displayed on the Page, Sort indicates the sorting method, and Page indicates whether to display pages.
Some other parameters are not listed in the following sections.
Is it like those CMS.
The middle is pure HTML, and it looks comfortable.
If you can write this statement without reporting an error, you can refer to my previous log, which contains an introduction.
Now, let's write it here. Next, I will introduce its principles.
The following knowledge is limited. If you are not clear about the introduction, please forgive me and leave a message if you have any questions.
Please be brave in making bricks !!!

 

From 19 shore

Related Article

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.