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>