Chapter 8 Implementation of the Administrator Page
So far, the basic functions of Doking's BLOG have been implemented. However, the administrator has the supreme "power of life and death" to strictly manage the notes and replies posted by users to prevent users from posting harmful information on Doking's BLOG.
(1) Create a new blank APS.NET VB dynamic page gllogin.aspx, insert the form glfrm, and then insert the table. The settings are as shown in Figure 8-1.
Figure 8-1 Page design of gllogin
(2) Let the ID of the text box corresponding to the administrator be GLY, and the ID of the text box corresponding to the password be GLPASS.
(3) Add the data set gly and set it to filter, as shown in Figure 8-2.
Figure 8-2 Add data set gly
(4) Click the "Advanced" button and add the parameter @GLPASS, as shown in Figure 8-3.
Figure 8-3 Add parameter @GLPASS
(5) In the data set gly advanced dialog box, change the SQL command to the one shown in Figure 8-4.
Figure 8-4 Data set gly advanced dialog box
(6) Switch to code view and insert the code shown in Figure 8-5 before the <html> tag.
Figure 8-5 Insert the code before the <html> tag
(7) and save gllogin.aspx.
From the previous section, you can see that after the administrator successfully logs in, he will be linked to the homepage of Doking's BLOG to manage study notes. However, in the previous chapters, index.aspx did not have the function of deleting study notes. This section will add this functionality to it.
(1) In the first row of table ztre, insert the asp label Label1 with the text: Delete, as shown in Figure 8-6.
Figure 8-6 Insert asp label Label1
(2) Right-click to select asp label Label1, select "Edit Label" under the shortcut menu, select "Style Information", and set it to invisible, as shown in Figure 8-7.
Figure 8-7 Set the asp label Label1 to be invisible
(3) Insert the check box under the form control and name it ZTID, and insert the button under the form control with the ID GLY. The result is shown in Figure 8-8.
Figure 8-8 In the settings (4) of table ztre
, switch to the [Properties] tab under the [Label] panel, expand the "General" item, and click dynamic data in the "value" item, as shown in Figure 8-9 .
Figure 8-9 ZTID label attribute panel
(5) In the pop-up "Dynamic Data" dialog box, select the field ZTID under the data set Ztre and press the "OK" key, as shown in Figure 8-10.
Figure 8-10 Dynamic data window
(6) Right-click on the status bar and select <input#ZIID> to open the quick edit label window, and add code to its label:
style="visibility: <%# iif(session("GLY") <>nothing,"visible","hidden")%>" value="<%# Ztre.FieldValue("ZTID", Container) %>"
as shown in dark blue in Figure 8-11.
Figure 8-11 Quickly edit the <input#ZIID> tag
(7) Select the button GLY, right-click on the status bar and select <input#GLY> to open the quick-edit tag window, and add code to its tag:
style="visibility: <% # iif(session("GLY")<>nothing,"visible","hidden")%>" value="<%# Ztre.FieldValue("ZTID", Container) %>"
(8) Add "Delete record "Server behavior, its settings are shown in Figure 8-12.
Figure 8-12 Adding the "Delete Record" server behavior
(9) Press the "OK" key to complete adding the "Delete Record" server behavior. Switch to the code view to find the original code of the "delete record" server behavior, as shown in the red circle in Figure 8-13.
Figure 8-13 The original code of the "Delete Record" server behavior
(10) Delete the codes on lines 5, 8, 12, 13, and 14 as shown in Figure 8-2-8, and set the value of Debug in line 10 to true Change it to false and add a new behavior: id="del1", as shown in the red circle in Figure 8-14 after modification.
Figure 8-14 The original code of the modified "delete record" del1 server behavior
(11) Copy the code shown in the red circle in Figure 8-2-9, that is, copy the original code of the modified "delete record" del1 server behavior, and change Paste it into the appropriate location and change the id to "del2", as shown in Figure 8-15.
Figure 8-15 Add del2 "delete record" server behavior
(12) Insert the code shown in the red circle in Figure 8-16 into the event page_load triggered by page loading.
Figure 8-16 Code inserted in the event page_load triggered by page loading
The principles and methods of note reply management and study note management are consistent.
(1) Open index.aspx, copy the asp label Label1, form control ZTID and button GLG, open hf.aspx, paste these three controls into the position shown in Figure 8-17, and change the ID of the form control ZTID to HFID.
Figure 8-17 Paste control to hf.aspx
(2) Select the check box HFID, switch to the [Properties] tab under the [Label] panel, expand the "General" item, and click Dynamic Data in the "value" item. In the pop-up "Dynamic Data" dialog box, select the field HFID under the data set Hfre and press the "OK" key, as shown in Figure 8-18.
Figure 8-18 Dynamic data window
(3) Copy "del1" in index.aspx to delete the original code that records service behavior, and paste it into hf.aspx.
(4) Insert the code shown in the red circle in Figure 8-19 into the page load trigger event page_load in the hf.aspx page.
Figure 8-19 Insert code into h page load trigger event page_load
(5) Find the original code of form yhplfrm and move it before the form ztre tag. The result is shown in Figure 8-20.
Figure 8-20 Move the label of the form yhplfrm
(6) Insert the code shown in the red circle in Figure 8-21 before the Hftab label of the form.
Figure 8-21 Insert code before the table Hftab tag
(7) Move the form yhplfrm end tag </form> after the table ztre tag, and insert the code shown in the red circle in Figure 8-22 after the table Hftab tag.
Figure 8-22 Insert code after the Hftab label of the table
to remind: There is also a problem of administrator logging out, which is left to the reader to use their brains. As a reminder, just set session("GLY") to a null value or empty string.