Dreamweaver
Completed the user's registration, users can now log into the Web site, to publish notes, notes reply.
7.1 User Logon server behavior
User login, verified correctly, the page changed a user login after the face.
(1) Open the template bkblog.dwt.aspx, insert the table Yhtab in the left column, and design as shown in the black circle in Figure 7-1.
(2) Insert a data set Yhlog about the YH table query to verify that the user is logged on correctly.
① Set the dataset Yhlog as a filter, as shown in Figure 7-2.
Fig. 7-1 The design diagram of the table Yhtab
Figure 7-2 Inserting data set Yhlog
② Click on the "Advanced" button to switch to Advanced dataset mode, as shown in Figure 7-3.
Figure 7-3 Inserting data set Yhlog
③ Click on the parameter "+", pop-up "Edit Parameters" dialog box, fill in the name "@Logpas", type Select "WChar", as shown in Figure 7-4.
Figure 7-4 Add to join Logpass
④ Click the "Build" button, pop-up "Generate Value" dialog box, named "Logpass", the source Select "Form variable", as shown in Figure 7-5.
Figure 7-5 Generate Value dialog box
⑤ Click OK to save the settings and go back to the DataSet Yhlog dialog box. Modify the SQL statement, as shown in Figure 7-6.
Figure 7-6 Modifying the dataset Yhlog
(3) before the
Figure 7-7 Defining a function Uselog
(4) Drag the data set in the template Bkblog.dwt.aspx yhlog the fields below the page yhname to any location, and then drag the field yhid the dataset Yhlog The following code is followed:
<%# Yhlog. Fieldvalue ("Yhname", Container)%><%# Yhlog. Fieldvalue ("Yhid", Container)%>
Change the code above to read:
<%# Uselog (Yhlog. Fieldvalue ("Yhname", Container), Yhlog. Fieldvalue ("Yhid", Container)%>
(5) Insert the data set BJRE on the ZT table query to return the total number of study notes published by the user.
① set the dataset to filter, filter fields: Yhid, and Filter by: Enter a value, as shown in Figure 7-8.
Figure 7-8 Inserting data set Bjre
② Click "Advanced" to switch to advanced dataset mode and modify the SQL as shown in Figure 7-9.
Figure 7-9 Modifying the dataset Bjre
③ Click the "Edit" button to change the Yhid to session ("Useid") in the Text field, as shown in Figure 7-10.
Figure 7-10 Editing the data set Bire parameters
④ Press "OK" and press "OK" to complete the dataset Bire.
(6) Insert the data set PLRE on the HF table query and return the total number of learning notes published by the user. In addition to the query table, the other settings are the same as the DataSet Bjre (you can copy and paste the dataset Plre before you modify it).
(7) Drag the field below the dataset Bjre Eprl100 to "Publish notes:" In the table Yhtab, and drag the fields under the Plre of the dataset Eprl100 to the "Post reply:" In table Yhtab.
(8) before moving the cursor to "user information" in table Yhtab, click "Bind data" under the ASP.net shortcut menu, and the result is shown in Figure 7-11.
Figure 7-11 Inserting bound data
Keep the cursor in the position of the red vertical line in Figure 71, enter: Session ("Usename")
(9) Return to Design view and create a hyperlink to "Publish New Notes" in the form Yhtab:. /ztfb.aspx
To create a hyperlink to "modify material" in the table Yhtab: ... /yhsg.aspx
The result is shown in Figure 7-12.
Figure 7-12 Modification of table Yhtab
(10) Select Table Yhtab, return to Code view, press "Ctrl+x" or select "Cut" from the Edit menu, and paste it into a newly created Notepad or Word document.
(11) Return to Design view, select Table Logtab, and move the cursor to the position of the red vertical line as shown in Figure 7-13.
Figure 7-13 Move to the cursor location
(12) Enter the code as shown in the red circle in Figure 7-14.
Figure 7-14 Inserting the code before the label <form>
(13) After moving the cursor to the YHLOGFRM end tag </form>, enter the code as shown in the red circle in Figure 7-15.
Figure 7-15 Insert code after label </form>
(14) <%end the table cut in step 7th Yhtab to the Code if%> code before <% else%>.
(15) Save the template bkblog.dwt.aspx. Open all Web pages that are based on the bkblog.dwt.aspx template, and copy and paste the newly added dataset in the bkblog.dwt.aspx template Yhlog, Bjre, Plre, respectively, in server behavior. Then insert code like Step 3rd, OK!
(16) Browse the index.aspx in IE browser, the user login is as shown in Figure 7-16, the user log on successfully as shown in Figure 7-17. Remember asp.net is not support gb2312 encoded transmission, to be modified, the previous chapter has said, no longer shiver.
Figure 7-16 before users log on
Figure 7-17 After the user logs in
Reminder: To facilitate the reader to learn, the tutorial is divided into modules to write. In fact, you have to do all the functions in the template at first, especially when the template must be inserted into the dataset and the header loader, because these can not update the Web page after late modification.
7.2 Users Post response information
Once the user is logged in, they can post a response message to each learning note.
(1) Open hf.aspx, insert form YHPLFRM, insert table Hftab, Insert server text box control in table, ID is hfname, insert server Text area control, ID is hftext, insert Publish button, ID is plbottom, set it to Disabled , the results are shown in Figure 7-18.
Fig. 7-18 Related design of table Hftab
(3) The Binding Data session ("Usename") to the "name:" In the table Hftab (method such as the user name before the "user information" is bound by the 7.1 Step 8 procedure).
(4) Drag the data set ztre the field ztname to the text box Hfname, in the Text box Hfname Properties window, the initial value:
<%# ztre.fieldvalue ("Ztname", Container)%>
To
<%# "RE:" &ztre.fieldvalue ("Ztname", Container)%>
(5) Select the button Plbottom, right-click the status bar < input # Plbottom>, and select Edit Label from the pop-up shortcut menu, as shown in Figure 7-19.
Figure 7-19 Selection < input # plbottom> quick edit tab
(6) In the pop-up < input # plbottom> Quick Edit tag:
Disabled= "true"
To
disabled=<%# IIF (Session ("Usename") <>nothing), false,true)%>
The result is shown in Figure 7-20.
Figure 7-20 Quick < input # plbottom> edit tags
The button Plbottom, which is disabled before the user logs on, is available after the user logs in.
(4) Add Insert record server behavior, submit value from form YHPLFRM, select Insert Table as HF, and other settings as shown in Figure 7-21.
Figure 7-21 Adding insert record server behavior
In Figure 7-21, you can see that the fields Hfid, Hftime, Yhid, Ztid do not get the values. The field Hfid is automatically numbered, the database automatically adds a value to the record, and the field hftime the default value in Access is date (), so the database automatically adds the day date to the newly added record. The field Yhid is the ID code of the logged-in user, and the field Ztid is the note ID to be published. So to add the ID code of the Logged-on user to the field Yhid, the note ID code to be published is added to the field Ztid.
(5) Go back to Code view and find the code for the Insert record (DKCONN,HF), as shown in Figure 7-22 Black selected section.
Figure 7-22 Finding the code for the Insert record (DKCONN,HF)
(6) The code:
commandtext= ' <%# ' INSERT into HF (Hfname, Hftext) VALUES (?,?,) "%>"
To
commandtext= ' <%# ' INSERT into HF (Hfname, Hftext, Ztid, Yhid) VALUES (?,?,?,?) "%>"
(7) Add parameters in sequence:
<parameter name= "@ZTID" Value= ' <%# ztre.fieldvalue ("Ztid", Container)%> ' type= ' "Integer"/>
<parameter name= "@YHID" Value= ' <%# session ("Useid")%> ' type= ' Integer '/>
The result is shown in Figure 7-23.
Figure 7-23 Modified results of the Insert record (DKCONN,HF) code
(8) Before the release of the reply message, the reply title and the content of the reply should be validated to prevent the release of empty headers or empty content of the reply information. Add the Requiredfieldvalidato validation control to the text box hfname, text area control Hftext, respectively, by inserting the Requiredfieldvalidato validation control method in Section 6.2.
(9) When the user publishes the reply information, also must give the study note the total number of replies automatically increases 1, namely gives the ZT table the Hfzs field automatically increases 1.
① in the Server Behaviors panel, insert the update record server behavior, set up the Update table for ZT, temporarily set the submission value, from the form YHPLFRM, temporarily set: ' Hfzs ' from ' hftext ' to get the value (as ' Integer '); temporarily set: ' Ztid ' will ' Hftext ' Use as ' Integer ' to select records
Why is the ② all temporary? That is to let Dreamweaver automatically generate some code, after easy to modify. Switch code view first, find the original code for the update record (DKCONN,ZT), and find the code:
<parameter name= "@HFZS" Value= ' <%# IIf (Request.Form ("Hftext") <> Nothing), Request.Form ("Hftext"), "" "% > ' type= ' Integer '/>
<parameter name= "@ZTID" Value= ' <%# IIf (Request.Form ("Hftext") <> Nothing), Request.Form ("Hftext"), "" "% > ' type= ' Integer '/>
Change it to:
<parameter name= "@HFZS" Value= ' <%# ztre.fieldvalue ("Hfzs", Container) +1%> ' type= ' Integer '/>
<parameter name= "@ZTID" Value= ' <%# session ("ZTANW")%> ' type= ' Integer '/>
(10) Save hf.aspx.
7.3 Users published Learning notes
After the user log in, in addition to can post the reply information, but also may publish the new study note.
(1) Create a Dynamic Web page ztfb.aspx by the template bkblog.dwt.aspx, insert a list of five elements in the mainbody editable region ZTFB.
(2) Add DataSet ZTHB, set Filter to Yhid, and set parameter as phase variable usename, its design is shown in Figure 7-24.
Figure 7-24 Adding data set ZTHB
(3) Drag the relevant field under the DataSet to the table ZTFB, by referring to the method in section 4.2.
(4) Open the Hf.aspx, copy the form yhplfrm, paste it into the page ztfb.aspx in the table ZTHB the fifth row, empty the text box hfname, and make the necessary changes, the results shown in Figure 7-25.
Fig. 7-25 Design of Table ZTFB
(2) renamed the text box Hfname as Ztname, and the text area Hftext renamed Zttext.
(3) Set the repeating region of the tertiary behavior DataSet ZTHB the table ZTHB, and insert the dataset navigation in the fourth row of the table.
(4) Insert list/menu Lmid, click the list value in its Properties window, in the Pop-up List Value dialog box, enter item label as: Design item, value is: 1, press "OK" key, as shown in Figure 7-26.
Figure 7-26 Lmid List Value dialog box
(5) Keep list/menu lmidl in the selection, switch to Code view, find the list/menu Lmid The original code, drag the DataSet Menuda the field Lmid, replace the value equals number 1, as shown in Figure 7-27.
Figure 7-27 dragging a field under the Menuda of a dataset Lmid
(6) Drag the field LM under the DataSet Menuda, replacing the design item, as shown in Figure 7-28.
Figure 7-28 dragging the field LM under the Menuda of the dataset
(7) Select the code in the red circle of the figure 7-3-5 and define it as a repeating region of the DataSet Menuda, as shown in Figure 7-29.
Figure 7-29 Defining a dataset in a list Menuda a repeating region
(8) Add the Insert record server behavior, which is set as shown in Figure 7-30.
Figure 7-30 Adding the Insert record server behavior
(9) Switch to Code view, find the inserted record (DKCONN,ZT) of the original code, find the code:
commandtext= ' <%# ' INSERT into ZT (Lmid, Ztname, Zytext) VALUES (?,?,?) "%>"
To
commandtext= ' <%# ' INSERT into ZT (Lmid, Ztname, Zytext,yhid) VALUES (?,?,?,?) "%>"
(10) Add Parameters:
<parameter name= "@YHID" Value= ' <%# session ("Useid")%> ' type= ' Integer '/>
The result is shown in Figure 7-31.
Figure 7-31 Insert Record (DKCONN,ZT) modified original code
7.4 Modify user Information
Modify user Information page design and user Registration page design is basically the same.
(1) Open the registration page yhlogok.aspx, save it as yhsg.aspx, and make appropriate changes, as shown in Figure 7-32.
Figure 7-32 yhsg.aspx Page Design
(2) Delete the Insert record (DKCONN,YH) server behavior and add the DataSet YHSG, as shown in Figure 7-33.
Figure 7-33 Inserting data set YHSG
(3) The relevant fields under the bound dataset YHSG to the corresponding text boxes, as shown in Figure 7-34.
Figure 7-34 Binding dynamic text to the text box
(4) Add update record server behavior, temporarily set: ' Yhid ' use ' yhname ' as ' Integer ' to select records, the result is shown in Figure 7-35.
Figure 7-35 Adding more logging server behavior
(5) in the more recorded source code, locate the code:
<parameter name= "@YHID" Value= ' <%# IIf (Request.Form ("Yhname") <> Nothing), Request.Form ("Yhname"), "" "% > ' type= ' Integer '/>
Change it to read:
<parameter name= "@YHID" Value= ' <%# IIf ((Not session ("Useid") are nothing), session ("Useid"), "" "%>" type= " Integer "/>
(6) Save yhsg.aspx.