Chapter 10 Implementation of BLOG Event Calendar
Since Doking's BLOG is a study note, you can check all notes and note responses by pressing the calendar.
Difficulty analysis: Should we add the Calendar calendar control directly to the template? No! That won't work! Since the Calendar calendar control is a server control, it must be in a form containing runat="server". However, there can only be one form containing runat="server" on a page, otherwise the error shown in Figure 10-1 will sometimes occur. show.
Figure 10-1 What should I do if the page can only have one error containing the runat="server" form
? Here is an embedded framework for transfer.
10.1 Add Calendar calendar control
(1) Create a new blank ASP.NET VB dynamic page.
(2) Insert and bring out the runat="server" form and set ID="Calfrm".
(3) Click the "More Tags" button under the ASP.NET shortcut menu, and select "asp Calendar" under "ASP.NET Tags" in the pop-up [Tag Selector] dialog box, as shown in Figure 10-2.
Figure 10-2 Insert the "asp Calendar" tag
(4) Press the "Insert" button, and the [Tag Editor—Calendar] dialog box will pop up, as shown in Figure 10-3. In this dialogue, you can set the style of the Calendar calendar control. Since it is in Chinese, I won’t go into details here.
(5) Save the ASP.NET VB dynamic page as dkCalendar.aspx. Browse in IE, as shown in Figure 10-4.
Figure 10-3 [Tag Editor—Calendar] dialog box
Figure 10-4 Browsing dkCalendar.aspx in IE
In Figure 10-1-4, you can see that the display of the week is too long and ugly! It would be nice if it read "day, one, two, three, four, five, six".
10.2 Modify the week display of Calendar
(1) Open dkCalendar.aspx in Dreamweaver, switch to the code view, and look for the following code:
<
%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
Change it to:
<%@ Page Language="VB" Debug="true" Culture="zh-CN"%>
(2) Click the "а:xy" button under the ASP.NET shortcut menu and insert the namespace, such as As shown in Figure 10-5.
(3) Add new code at this time:
<%@ Import Namespace="" %>
The input namespace is System.Globalization, that is, the code is changed to:
<%@ Import Namespace="System.Globalization" %>
(4) Add again Namespace System.Threading, the result is shown in Figure 10-6.
Figure 10-5 Inserting namespace
Figure 10-6 Code after inserting the namespace
(5) After the code:
<%@ Import Namespace="System.Treading" %>
, leave a blank line and insert the following code:
<script runat="server">
Dim dkday' definition The global variable of the link string generated by selecting the date
'function to change the week display
Private Sub Calendar1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.PreRender
Dim dkwek = System.Threading.Thread.CurrentThread
Dim dknew = System.Globalization.CultureInfo.CurrentCulture.Clone()
dknew.DateTimeFormat.DayNames = New String() {"Day", "一", "二", "三", "四", "五", "六"}
dknew.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday
dkwek.CurrentCulture = dknew
End Sub
</script>
(6) Select the original code of the calendar control Calendar1, switch to the [Properties] tab of the [Label] panel, expand the "Appearance" option, Select the drop-down menu of the "DayNameFormat" item and select "Full", as shown in Figure 10-7.
(7) Save dkCalendar.aspx and browse it in IE. The result is shown in Figure 10-8.
Figure 10-7 Select the "DayNameFormat" value as "Full" Figure 10-8Add calendar events
in IE 10.3 after modifying dkCalendar.aspx
(1) Open dkCalendar.aspx in Dreamweaver, switch to code view, and select the original code of Calendar1 , right-click it and select "Edit Label (E) <asp:calendar>" in the pop-up shortcut menu, as shown in Figure 10-9.
Figure 10-9 Select "Edit Label (E) <asp:calendar>"
(2) In the dialog box that pops up [Edit Label—calendar], expand the "Events" item, select "OnSelectionChanged", and click "Calendar—OnSelectionChanged" In the event text area, enter "Calendar1_SelectionChanged" and press the "OK" button, as shown in Figure 10-10.
Figure 10-10 Edit the OnSelectionChanged event
(3) Add the code shown in the red circle in Figure 10-11 in the code <script runat="server"> tag.
Figure 10-11 Add Calendar1_SelectionChanged event
(4) Between the tags <head></head>, insert the code shown in the red circle in Figure 10-12.
(5) Find the tag <body> and change it to the code shown in the red circle in Figure 10-13.
Figure 10-12 Inserting the javascript function dkwk
Figure 10-13 Modify the tag <body>
(6) Set the "DayNameFormat" item of Calendar1 to "Full" again, refer to step 6 in Section 10.2.
(7) Save dkCalendar.aspx, open index.aspx, and add the following code in the page_load function:
if Request.QueryString("dkday")<>nothing then
Ztre.CommandText="SELECT * FROM ZTRE WHERE cstr(ZITIME) LIKE ' %" &Request.QueryString("dkday")&"%' ORDER BY ZITIME DESC"
else
if (request.QueryString("menanw")<>nothing) or (session("menanw")<>nothing) then
Ztre.CommandText ="SELECT * FROM ZTRE WHERE LMID = ? ORDER BY ZITIME DESC"
else
Ztre.CommandText="SELECT * FROM ZTRE ORDER BY ZITIME DESC"
end if
end if
The result is shown in Figure 10-14.
Figure 10-14 Add code (8) in the page_load function
to find the original code of the record set Ztre and delete the command line where its CommandText is located. The result is shown in the red circle in Figure 10-15.
Figure 10-15 The original code (9) of the modified record set Ztre
saves index.aspx.
10.4 Add an embedded frame
(1) Open the template dkblog.dwt.aspx, click the "More Tags" shortcut button in the ASP.NET shortcut menu, and select "HTML Tags" in the [Tag Selector] dialog box that pops up. And select the "iframe" item, as shown in Figure 10-16.
Figure 10-16 Insert iframe tag (i.e. embedded frame)
(2) Click the "Insert" button, and in the pop-up [Tag Editor—iframe] dialog box, make relevant settings for the embedded frame to be inserted, as shown in Figure 10-17 shown.
Figure 10-17 Make relevant settings for the embedded frame
(3) Press the "OK" button to return to the [Tag Editor—iframe] dialog box, and then press the "Close" button.
(4) Save the template dkblog.dwt.aspx and update all web pages.
(5) Browse index.aspx in IE, the result is shown in Figure 10-18.
Figure 10-18 Browsing index.aspx in IE
Reminder: In fact, the implementation of calendar events is a very complex event, here is just a simple example. Another difficulty in this section is the control of the main window object by the embedded framework. Here we only use " parent.location.href " to control the flow of the main window web page. These are left to the readers to study slowly.