dreamweaver| Calendar
Tenth chapter The Realization of blog Event Calendar
Since Doking's blog is a learning note, you can find all notes and notes replies by Calendar.
Difficulty Analysis: Do you want to add a calendar control directly to the template? No! That's not going to work! Because the Calendar Calendar control is a server control, you will sometimes see the error shown in Figure 10-1 if you want to include the server control in the runat= "Server" form, but only one of the pages contains a runat= "Server" form.
Figure 10-1 The page can have only one error containing the runat= "Server" form
Then what? Here is the adoption of an embedded framework for transfer.
10.1 Add Calendar Control
(1) Create a new blank asp.net vb dynamic page.
(2) Insert the runat= "Server" form and set id= "Calfrm".
(3) Click on the "More tags" button under the ASP.net shortcut menu, and select "ASP Calendar" under "asp.net tag" in the Pop-up Tag Selector dialog box, as shown in Figure 10-2.
Figure 10-2 Inserting the ASP Calendar tab
(4) Press the "Insert" button, pop-up "tag Editor-calendar" dialog box, as shown in Figure 10-3. In this dialog, you can set the style of the calendar control, which is not spoken here because it has Chinese.
(5) Save asp.net VB dynamic page for dkcalendar.aspx. Browse in IE, as shown in Figure 10-4.
Figure 10-3 "Tag Editor-calendar" dialog box
Figure 10-4 dkcalendar.aspx browsing in IE
In Figure 10-1-4, you can see that the week's display is too long, it's hard to see! If the display is "day, one or two, three or four, five or six", that's fine.
10.2 Change Calendar Week display
(1) Open dkcalendar.aspx in Dreamweaver, switch to 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 to insert the namespace, 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 should read:
<%@ Import namespace= "System.Globalization"%>
(4) Add the namespace system.threading, and the result is shown in Figure 10-6.
Figure 10-5 Inserting a namespace
Figure 10-6 code after inserting a namespace
(5) in the code:
<%@ Import namespace= "system.treading"%>
After that, empty a line and insert the following code:
<script runat= "Server" >
Dim Dkday ' defines a global variable for the link string generated by the selection date
' Change the week display function
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", "one", "two", "three", "four", "five", "six"}
Dknew. Datetimeformat.firstdayofweek = DayOfWeek.Sunday
Dkwek. CurrentCulture = Dknew
End Sub
</script>
(6) Select the original code for the Calendar control Calendar1, switch to the Properties tab of the tags panel, expand the Appearance option, select the Drop-down menu for the DayNameFormat item, and select Full, as shown in Figure 10-7.
(7) Save dkcalendar.aspx, browse in IE, the result is shown in Figure 10-8.
Figure 10-7 Select the "DayNameFormat" value of "full" figure 10-8 dkcalendar.aspx modified in IE browse
10.3 Adding calendar events
(1) Open dkcalendar.aspx in Dreamweaver, switch to Code view, select Calendar1 code, right-click it, and choose Edit Label (E) <asp:calendar> on the pop-up shortcut menu. As shown in Figure 10-9.
Figure 10-9 Selecting the Edit label (E) <asp:calendar>
(2) in the pop-up "Edit label-calendar" dialog box, expand the Events item, select "OnSelectionChanged", in the "calendar-onselectionchanged" Event text area, enter "calendar1_ SelectionChanged, press the OK button, as shown in Figure 10-10.
Figure 10-10 Editing the OnSelectionChanged event
(3) Add code in the code <script runat= "Server" > tags as shown in the red circle in Figure 10-11.
Figure 10-11 Adding the Calendar1_SelectionChanged event
(4) Insert the code shown in the red circle of figure 10-12 between the label
(5) Find the label <body>, and change it to the code shown in the red circle in Figure 10-13.
Figure 10-12 Inserting a JavaScript function dkwk
Figure 10-13 Modifying labels <body>
(6) Once again, set the Calendar1 "DayNameFormat" to "full" and refer to the 6th step in section 10.2.
(7) Save dkcalendar.aspx, open index.aspx, 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 Zitim E 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 Adding code to the Page_Load function
(8) Locate the original code of the recordset Ztre, and delete the command line where the Commantext is located, as shown in the red circle in Figure 10-15.
Figure 10-15 The original code for the modified recordset Ztre
(9) Save index.aspx.
10.4 Adding embedded Frames
(1) Open the template dkblog.dwt.aspx, in the ASP.net shortcut menu, click the "More tags" shortcut button, in the pop-up "tag Selector" dialog box, select "HTML Tag", and select "IFRAME" Item, as shown in Figure 10-16.
Figure 10-16 Inserting an IFRAME label (that is, an inline frame)
(2) Click the Insert button to set the embedded frame you want to insert in the Tag Editor-iframe dialog box as shown in Figure 10-17.
Figure 10-17 Setting the embedded framework
(3) Press the "OK" button, return to the Label Editor-iframe dialog box, and then press the "Close" button.
(4) Save the template dkblog.dwt.aspx and update all 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, and here is just a simple example. This section also has a difficulty is the embedded framework of the main Window object control, here is only a "parent.location.href" control of the main window of the page flow. This is left to the reader to study slowly.