Micro Project Practice (11): Control and formatting display

Source: Internet
Author: User

In the previous article, we briefly analyzed the design of the page, today we look at the dynamic part of the page. The main controls in the master and default pages are the following tables:

Control ID Describe
Calendar ASP.net's own calendar control, using its own style, we'll use the control to implement queries based on dates later.
Listview_blogclass ListView, used to display log classifications. The control generates HTML that is all connected and does not need to respond to events, so EnableViewState is set to false.
Listview_bloglist ListView, for displaying logs. The control needs to respond to part of the event, so the enableviewstate of some of its child controls is set to false, and the part that needs to respond to the event is set to true.
Literalpagecount Literal, for displaying paging. This control is used in conjunction with our own paging helper.

In the page, there are many need to format the display of the place, such as the system to specify the date of the display rule is: if the time of cent seconds are zero, then use a similar "May 27, 2008" Way to display, otherwise, use the "May 27, 2008 10:02:59" way to display ; There are also truncation of strings, Boolean classes using the Yes/no display, empty strings using " " Display, as well as the display of various enumeration types. For such a display rule, we use the extension method to implement it. The display of the date uses the following code (located in \dongblog.ui\toshowextension.cs):

1:///<summary>
2:///Display date
3:///</summary>
4:///<param name= "DateTime" > Date to display ;/param>
5:///<returns> Date string </returns>
6:public static string Toshow (this datetime datetime)
7: {
8:if (datetime.timeofday = = TimeSpan.Zero)
9:return string. Format ("{0:yyyy mm month DD day}", dateTime);
10:else
11:return String. Format ("{0:yyyy mm month DD day} {0:t}", dateTime);
13:}

In Listview_bloglist, this method is used to display the update time for the log:

<div runat= "Server" enableviewstate= "false" class= "Blogupdatedatetime" >
<%# (DateTime) Eval (" Updatedatetime ")). Toshow ()%>
</div>

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.