The 7th chapter Doking's BLOG user logs onto the implementation of the page
Already finished the enrollment of the user, the user can log onto a website now in, publish response of note, note.
7.1 The user logs onto server behavior
The user logins, course test and verify is correct, the page changed a face after the user logins.
(1) open pattern plate Bkblog.dwt.aspx, to the left column inserts form Yhtab, if the place in circle of graph 7-1 black is shown,design.
(2) insert the data set Yhlog that expresses inquiry about YH, what login with user of test and verify is correct.
① sets data set Yhlog to choose, if pursue,7-2 place is shown.
Graph 7-1 The blueprint of form Yhtab
Graph 7-2 Insert data set Yhlog
② is clicked " advanced " pushbutton, switch occupies market pattern to tall progression, if pursue,7-3 place is shown.
Graph 7-3 Insert data set Yhlog
③ clicks parameter " + " , play piece " editor parameter " dialog box, fill in the name is " @Logpas " , the type chooses " WChar " , if pursue,7-4 place is shown.
Graph 7-4 Add attend Logpass
④ is clicked " build " pushbutton, play piece " create a value " dialog box, the name is " Logpass " , the source chooses " the variable that express sheet " , if pursue,7-5 place is shown.
Graph 7-5 Make value dialog box
⑤ is clicked " affirmatory " save a setting, return dialog box of data set Yhlog all the time. Modification SQL statement, modification result is shown like graph 7-6 place.
Graph 7-6 Undertake modification to data set Yhlog
(3) before <html> label, if graph 7-7 red encircles shows code,insert.
Graph 7-7 Define function Uselog
(4) the field YHNAME below the data set Yhlog in Bkblog.dwt.aspx of dilatory pattern plate arrives any page positions, the field YHID below Yhlog of again dilatory data set is in ever since, code is as follows:
<%# Yhlog.FieldValue("YHNAME" , container) %><%# Yhlog.FieldValue("YHID" , container) %>
Above code instead:
<%# Uselog(yhlog.FieldValue("YHNAME" , container) , yhlog.FieldValue("YHID" , container)) %>
(5) insert the data set Bjre that expresses inquiry about ZT, return the study note number that this user publishs.
① establishs data set for " choose " , choose a field to be: YHID, choose means to be: Input value, if pursue,7-8 place is shown.
Graph 7-8 Insert data set Bjre
② is clicked " advanced " , switch occupies market pattern to tall progression, revise SQL.
Graph 7-9 Bjre of modification data set
③ is clicked " editor " pushbutton, in text inside the country YHID instead Session(" USEID " ) , if pursue,as a result 7-10 place is shown.
Graph 7-10 Edit the parameter of data set Bire
④ is pressed " affirmatory " key, press again " affirmatory " Bire of the key data set that finish.
(6) insert the data set Plre that expresses inquiry about HF, return the study note number that this user publishs. Besides inquiring the list is diverse, other setting and data set Bjre are identical (can duplicate first Plre of stickup data set, reentry is revised all right) .
(7) the field Eprl100 below Bjre of dilatory data set in form Yhtab " publish note: " later; The field Eprl100 below Plre of dilatory data set in form Yhtab " publish a response: " later.
(8) move cursor in form Yhtab " user information " before, click ASP.NET quick menu to fall " bind destiny to occupy " , if pursue,as a result 7-11 place is shown.
Graph 7-11 Insert bind destiny to occupy
Maintain cursor to be in graph the position of 71 gules perpendicular, input: Session(" USENAME " )
(9) return design view, in giving form Yhtab " publish new note " establish super link: . . / Ztfb.aspx
In giving form Yhtab " modification data " establish super link: . . / Yhsg.aspx
If pursue,as a result 7-12 place is shown.
Graph 7-12 The modification of form Yhtab
(10) choice form Yhtab, return code view, by " Ctrl+X " or in [editor] the choice in menu " cut " , old method: it stickup in building newly-built notebook or Word documentation.
(11) return design view, choose form Logtab, move cursor to the position of the gules perpendicular that shows like graph 7-13 place.
Graph 7-13 Move to be in the position to cursor
(12) input code, if graph 7-14 is gules,the place in the circle is shown.
Graph 7-14 Code is inserted before label <form>
(13) after moving cursor to Yhlogfrm to end label </form> , input code, if graph 7-15 is gules,the place in the circle is shown.
Graph 7-15 Code is inserted after label </form>
(14) the form Yhtab that cuts in the 7th pace stickup in code <%end Before If%> code, after <% Else %> .
(15) save pattern plate Bkblog.dwt.aspx. Open all webpages that build basically at Bkblog.dwt.aspx pattern plate, be in respectively [server behavior] medium a Bkblog.dwt.aspx pattern plate is medium new additive data set Yhlog, Bjre, Plre, duplicate, stickup come over. Insert the code that is like the 3rd measure again, with respect to OK!
(16) Index.aspx is browsed in IE browser, before the user logins, like graph 7-16 place is shown, if graph 7-17 place is shown,the user logs onto a success. Remembering ASP.NET is not to support Gb2312 encode to transmit, want to undertake modification, already had said in on one chapter, later no longer shiver.
Graph 7-16 Before the user logins
Graph 7-17 After the user logins
Remind: Learn for convenient reader, tutorial cent is written into module. Had to have done in all functions in pattern plate at the beginning actually, the data set that must insert in pattern plate especially and page head loader, because these cannot update a webpage after later period is revised.
7.2 The user publishs return information
After the user logins, can learn note to publish return information to each.
(1) open Hf.aspx, insert the Yhplfrm that express sheet, insert form Hftab again, server text casing is inserted to accuse in form, ID is HFNAME; Insert server text area to accuse, ID is HFTEXT; Insert " publish " pushbutton, ID is Plbottom, set its use to ban, if pursue,as a result 7-18 place is shown.
Graph 7-18 The concerned design of form Hftab
(3) bind destiny to occupy Session(" Usename " ) in form Hftab " full name: " later (the method is bound like 7.1 the 8th measure calm " user information " the user name before) .
(4) the field ZTNAME below Ztre of dilatory data set arrives text casing HFNAME, in the attribute window of text casing HFNAME, initiative value:
<%# Ztre.FieldValue("ZTNAME" , container) %>
Instead:
<%# "RE: " &Ztre.FieldValue("ZTNAME" , container) %>
(5) choice pushbutton Plbottom, right key chooses condition column<Input # Plbottom> , choose in playing a quick menu " editor label " , if pursue,7-19 place is shown.
Graph 7-19 Choice<Label of quick editor of Input # Plbottom>
(6) playing those who go out<In label of quick editor of Input # Plbottom> :
Disabled= " True "
Instead:
Disabled=<%# Iif((session("USENAME")<>nothing) , false, true) %>
If pursue,as a result 7-20 place is shown.
Graph 7-20 Quick<Input # Plbottom> edits label
Set pushbutton Plbottom namely, before loginning when the user, use to ban, after the user logins, be usable.
(4) add insert record server behavior, refer a value to come from the Yhplfrm that express sheet, the choice inserts form to be HF, other setting is shown like graph 7-21 place.
Graph 7-21 Add insert record server behavior
In graph 7-21, can see field HFID, HFTIME, YHID, ZTID did not get a value. Field HFID is automatic number, the database can add numerical value automatically to the record; Field HFTIME already set acquiescent value to be Date() in Access, so the database can give automatically new addition record is added when nature date. That field YHID logs onto the ID of the user to pile up namely, field ZTID wants published note ID namely. The ID yard that wants an entry user so is added in field YHID, the note ID code that should publish is added in field ZTID.
(5) return code view, find insert a record (Dkconn, HF) code, if pursue,7-22 black already selected a part.
Graph 7-22 Find insert a record (Dkconn, HF) code
(6) code:
CommandText='<%# "INSERT INTO HF (HFNAME, HFTEXT) VALUES (? , ? , ) " %>'
Instead:
CommandText='<%# "INSERT INTO HF (HFNAME, HFTEXT, ZTID, YHID) VALUES (? , ? , ? , ? ) " %>'
(7) add parameter by order:
<Parameter Name="@ZTID " Value='<%# Ztre.FieldValue("ZTID" , container) %>' Type="Integer " / >
<Parameter Name="@YHID " Value='<%# SESSION("USEID" ) %>' Type="Integer " / >
If pursue,as a result 7-23 place is shown.
Graph 7-23 Insert a record (Dkconn, HF) the modification result of code
(8) before releasing return information, the content of right reply caption and reply undertakes test and verify, prevent to release the return information of empty caption or empty content. Consult 6.2 RequiredFieldValidato test and verify is inserted to charge a means in the section, accuse a HFTEXT to add RequiredFieldValidato test and verify to accuse to area of text casing HFNAME, text respectively.
(9) when the user releases return information, returns so that give study note reply number increases automatically 1, the HFZS field that leaves to ZT watch namely increases automatically 1.
① is in [server behavior] in face plate, insert " update a record " server behavior, set newer form to be ZT, set temporarily submit a cost, come from the Yhplfrm that express sheet, set temporarily: ' HFZS ' from ' HFTEXT ' get a value (as ' Integer ' ) ; Set temporarily: ' ZTID ' will ' HFTEXT ' use as ' Integer ' will choose a record
Why is ② temporary completely? That is to make Dreamweaver automatic generate a few code first, just revise after. Cut replacement to pile up view first, find newer record (Dkconn, ZT) former code, find among them 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" />
its instead:
<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 The user publishs study note
After the user logins, besides can publish return information, still can publish new study note.
(1) build generate dynamic webpage Ztfb.aspx by pattern plate Bkblog.dwt.aspx, the form Ztfb that a the five elements inserts in area can edit in Mainbody.
(2) add data set Zthb, set choose for YHID, set parameter to be level variable USENAME, if graph 7-24 place is shown,its are designed.
Graph 7-24 Add data set Zthb
(3) the concerned field below dilatory data set arrives in form Ztfb, the method consults the 4.2nd method.
(4) open Hf.aspx, the duplicate Yhplfrm that express sheet, it stickup the the five elements of the form Zthb in webpage Ztfb.aspx, HFNAME of casing of clear empty text, undertake be modificationed necessarily, if pursue,as a result 7-25 place is shown.
Graph 7-25 The design of form Ztfb
(2) text casing HFNAME incognito for ZTNAME, text area HFTEXT is incognito for ZTTEXT.
(3) set form Zthb the first, 2, of Zthb of 3 behavior data set repeat area, be in the 4th of form again in insert data set navigation.
(4) insert list / menu LMID, click the tabulated value in its attribute window, in shooting the tabulated value dialog box that give, input project tag to be: Design; The value is: 1, press " affirmatory " key, if pursue,7-26 place is shown.
Graph 7-26 Dialog box of LMID tabulated value
(5) maintain list / menu LMIDl is being chosen, switch arrives code view, find list / the former code of menu LMID, the field LMID below Menuda of dilatory data set, the data that replaces Value to be equal to date 1, if pursue,7-27 place is shown.
Graph 7-27 The field LMID below Menuda of dilatory data set
(6) the field LM below Menuda of dilatory data set, replace " design " , if pursue,as a result 7-28 place is shown.
Graph 7-28 The field LM below Menuda of dilatory data set
(7) the code in choosing graph 7-3-5 red to encircle, define it those who be data set Menuda to repeat area, if pursue,as a result 7-29 place is shown.
Graph 7-29 The data set Menuda in defining list repeats area
(8) add " insert a record " server behavior, if graph 7-30 place is shown,its are installed.
Graph 7-30 Add " insert a record " server behavior
(9) switch arrives code view, find insert a record (Dkconn, the former code of ZT) , find code:
CommandText='<%# "INSERT INTO ZT (LMID, ZTNAME, ZYTEXT) VALUES (? , ? , ? ) " %>'
Instead:
CommandText='<%# "INSERT INTO ZT (LMID, ZTNAME, ZYTEXT, YHID) VALUES (? , ? , ? , ? ) " %>'
(10) add parameter:
<Parameter Name="@YHID" Value='<%# Session("USEID") %>' Type="Integer" />
If pursue,as a result 7-31 place is shown.
Graph 7-31 Insert a record (Dkconn, the former code that ZT) amends
7.4 Modification user data
Design of page of modification user data and user register a page the design is basic and identical.
(1) open register page Yhlogok.aspx, put it additionally for Yhsg.aspx, undertake be modificationed appropriately, if pursue,as a result 7-32 place is shown.
Graph 7-32 Yhsg.aspx page is designed
(2) delete " insert a record (Dkconn, YH) " server behavior, add data set Yhsg, if pursue,7-33 place is shown.
Graph 7-33 Insert data set Yhsg
(3) the concerned field that binds destiny to fall according to collect Yhsg arrives in corresponding text casing, if pursue,as a result 7-34 place is shown.
Graph 7-34 Bind calm trends text to arrive in concerned text casing
(4) add behavior of newer record server, set temporarily: ' YHID ' will ' YHNAME ' use as ' Integer ' will choose a record, if pursue,as a result 7-35 place is shown.
Graph 7-35 Add more record server behavior
(5) be in more in the former code of the record, find code:
<Parameter Name="@YHID" Value='<%# IIf((Request.Form("YHNAME") <>Nothing) , request.Form("YHNAME") , "") %>' Type="Integer" />
its instead:
<Parameter Name="@YHID" Value='<%# IIf((Not Session("USEID") Is Nothing) , session("USEID") , "") %>' Type="Integer" />
(6) save Yhsg.aspx.

No comments:
Post a Comment