Title: ASP.NET and Web ?pplications
1(No Transcript)
2ASP.NET ??? ???????? ??????????
???????????? ?? .NET Framework
http//www.nakov.com/dotnet/
?????? ??????? Microsoft Student
Consultant www.fmi.uni-sofia.bg/microsoft/
3?????????? ??????
- ?????? ???????? ?? ????? C
- ?????? ???????? ?? ????????????? ?? .NET
Framework - ??????????? ?? ???-?????????? ??????????
- ?????? ???????? ?? Internet
- HTTP (Hyper Text Transfer Protocol)
- HTML (Hyper Text Markup Language)
4??????????
- ?????????
- ??? ?????
- ????????
- Code Behind
- ???????
- ???????????? ? ?????????
- ?????????
- ?????? ? ???? ?? ?????
- State Management
- ????????????, ??????????? ? ??????????
- ?????????
- ??????? ???????
- IIS
5?????????? - ?????????
- ??????????? ?? ASP.NET
- ASP.NET Web Application Execution
- ??????? ?? ASP.NET
- ?????? ?? ASP.NET
- ??? ?????? ASP.NET
- ????????? ?? ???????????? ?? ?????? ??????
- ?????????? ?? ASP.NET
- ????????????
- Visual Studio ASP.NET Application
- ASP.NET Execution Model
6??????????? ?? ASP.NET
- ASP.NET ? ?????????? ?? ???????, ????? ???????
?????????, ?? ?? ????????? HTTP ?????? - ?????? ? ????, ??????? ?? ???????
- ????????? ?????? ?? ASP.NET (ASP.NET worker
process) ? ??????? ????????????? ?????? ?? IIS - ?????????? ? ASP.NET ?? ?????? ??????????? ??
.NET ??????? - ???????? ?? ? ????????? (.DLL ???????)
7?????????? ?? ASP.NET ??? ??????????
- ASP.NET ??? ???????????? ?? ?????????? ???? ?????
?? HTTP ?????? ? ???????? ????? ???????????
???????? ? ??? ???????
8??????? ?? ASP.NET (1)
- ASP.NET ? ????????? ?????????, ???????????? ??
.NET Framework, ?? ?????????? ?? ??? ?????????? ?
??? ?????? - ASP ? ?????????? ?? Active Server Pages
9??????? ?? ASP.NET (2)
- ???? ???? ASP, ASP.NET ?????? ?? ??? ?????? ?
?????????? ?????????? ?? ?????????? ??
????????????, ?????????, ??????????????? ???
???????
10?????? ?? ASP.NET (1)
- ??? ??????? (Web form)
- ????????? ????????? ?? ASP.NET
- ??? ??????????, ????? ????????????? ?????? ?
???????? ??
11?????? ?? ASP.NET (2)
- ????? ASP.NET ?????????? ??????? ???? ??? ??????
??? ?????
12??? ?????? ASP.NET (1)
- ????????????? ??? ???????? ????? ?? ??????????
??? ?? ?????????? ???????, ?? ?? ?????????
??-?????? ????????
13??? ?????? ASP.NET (2)
- ????????????? ??? ???????? ????? ?? ??????????
??? ?? ?????????? ???????, ?? ?? ????????
??-?????? ???????? - ASP.NET ??? ??????? ???? ?? ????????? server-side
??? - ?????? ?? ???? ?????, ????????? ????????,
??-?????? ?????????, ...
14??? ?????? ASP.NET (3)
- ASP.NET ??? ??????? ??????????? ???? ???? ???
HTML ? ???????????? ???????? ?? ?????????? ??
????????????? ??????? ?/??? ????????
15????????? ?? ???????????? ?? ?????? ?????? (1)
- ????????? HTML ? ???????? ???, ????? ???
?????????? ?????? ?? ?????????, ????????? ?
???????? - ?????????????? ?? ?????????? ????????? (UI) ??
??????? ?? ??? ???????? ????? - ?? ???????????? ?? ???????? HTML ???, ??????? ???
???? ? ?????????? .aspx - ?????? ???????? ?? ???????? ? ??????? ???? (?
?????????? .cs ?? C), ???????? ???????????
????????????? ???? ????????? ???? - ??????, ???????? ?????? ????????, ?? ??????
"?????????? ??? ?? ??? ???????" ("Code Behind")
16????????? ?? ???????????? ?? ?????? ?????? (2)
- ??????, ????????? ?? .aspx ????, ????????? ????
???????? ???? ?????? ???????? ?? Page ????? - ?????????? ???? ?? ?????? "??????????? ????"
(code-behind class), ?????? ????? ????? ??
???????? ??????, ????????? ?? ??????? ? ??. - ???? "?????????? ???" ????????????? ? ?????????
?? ????????, ????? ????? .aspx ???????? ?? ?????
?? ?????????
System.Web.UI.Page
WebForm1.aspx.cs
WebForm1.aspx
17?????????? ?? ASP.NET
- Web Forms ???????? ?????????? ?? ASP.NET
?????????? - Code-behind ????????? ?? ? ??? ????? ? ????????
server-side ??? - Web.config ????, ???????? ?????????????? ??
ASP.NET ???????????? - Machine.config ???? ? ???????? ????????? ?? ???
??????? - Global.asax ????, ???????? ??? ?? ?????????? ??
application-level ???????
18???????????? 1
- ??????? ?????????? ?? ASP.NET ??????????
19Visual Studio ASP.NET Application
20ASP.NET Execution Model (1)
- ???????, ?????? ?????? ?? ????? ??? ???????
?????? ?? ??? ????????
21ASP.NET Execution Model (2)
- ASP.NET parser-?? ??????? ???? ????
22ASP.NET Execution Model (3)
- ??? ????? ?? ? ??? ??? ??????????, ASP.NET
??????? ???????????
23ASP.NET Execution Model (4)
- ????? ?? ?????????, ??? ???? ?? ? ??????????, ?
?? ??????? ? ????
24ASP.NET Execution Model (5)
- ??????? (CLR) ??????? ? ????????? MSIL ????
25ASP.NET Execution Model (6)
- ?????????? ?? ????? ?? ???????
26ASP.NET Execution Model (7)
- ??? ???????? ?????? ????? ?? ????? ???????? ??
????, ?? ?? ? ??-?????
27?????????? - ??? ?????
- ????? ? ??? ????? (Web Form)
- ????????? ?? ??? ?????
- ?????????
- ??????????? _at_Page
- ???????? ?? lt_at_Page gt
- ltformgt
- ???????? ?? ltformgt ????
- ?????? WebForm1.aspx
- ???????? ?????? ? ASP.NET
- ???????? ????????
- ???????????? ?? ??????
- ????????????
28????? ? ??? ????? (Web Form)
- ????????????? ??? ????????
- ????? ?? ????????????? ????????? (UI) ?? ASP.NET
?????????? - ?????? ?? ?? HTML, ??? ? ????????, ????? ??
?????????? ?? ??? ?????? - ???????????? ????? ?????????, ???? ???????? HTML,
????????? ?? ??? ??????? - ????? ? ??????????, ????? ??????? ??? ???????, ??
???????? ???????
29????????? ?? ??? ????? (1)
lt_at_ Page Language"c" Codebehind"WebForm1.aspx.
cs" Inherits"WebApplication1.WebForm1"gt lthtmlgt
ltheadgtlttitlegtWebForm1lt/titlegtlt/headgt ltbody
MS_POSITIONING"GridLayout"gt ltform id"Form1"
method"post"gt ltaspButton ...gtlt/aspButtongt
lt/formgt lt/bodygt lt/htmlgt
- ????????? ?? ??? ??????? ?? ?????????, ???? ??
????????? ??? ???? ?? ????????
30????????? ?? ??? ????? (2)
lt_at_ Page Language"c" Codebehind"WebForm1.aspx.
cs" Inherits"WebApplication1.WebForm1"gt lthtmlgt
ltheadgtlttitlegtWebForm1lt/titlegtlt/headgt ltbody
MS_POSITIONING"GridLayout"gt ltform id"Form1"
method"post"gt ltaspButton ...gtlt/aspButtongt
lt/formgt lt/bodygt lt/htmlgt
- Page ?????????? ????????? ???????? ??????????????
31????????? ?? ??? ????? (3)
lt_at_ Page Language"c" Codebehind"WebForm1.aspx.
cs" Inherits"WebApplication1.WebForm1"gt lthtmlgt
ltheadgtlttitlegtWebForm1lt/titlegtlt/headgt ltbody
MS_POSITIONING"GridLayout"gt ltform id"Form1"
method"post"gt ltaspButton ...gtlt/aspButtongt lt
/formgt lt/bodygt lt/htmlgt
- body ???????? ????????? ??? ?? ?? ?????? ????
???????? - MS_POSITIONINGFlowLayout, GridLayout
32????????? ?? ??? ????? (4)
lt_at_ Page Language"c" Codebehind"WebForm1.aspx.
cs" Inherits"WebApplication1.WebForm1"gt lthtmlgt
ltheadgtlttitlegtWebForm1lt/titlegtlt/headgt ltbody
MS_POSITIONING"GridLayout"gt ltform id"Form1"
method"post"gt ltaspButton ...gtlt/aspButtongt
lt/formgt lt/bodygt lt/htmlgt
- form ?????????? ????????? ??? ??????? ???????? ??
?? ?????????
33?????????
- ??????????? ?????????? ?? ?? ??????????? ?????
?????, ??????? ????? ???????????? ? ????????????
?? ??? ??????? - ????? ?????????
- _at_Page ?????? ????????? ?? ??????? (??-?????
??????????) - _at_Import ??????? ????? namespace ??? ???????
- _at_Assembly ??????? ??????? ? ???????, ??????
???? ??????????? - _at_OutputCache ?????????? ???????????? ??
???????? ?? ??????? - _at_Register ?????????? ??????? ?? ???????? ? ???
?????
34??????????? _at_Page
- ???????? ?????????? ?? ??????? (.aspx file)
????????, ?????????? ?? ??????? ? ??????????? ??
ASP.NET - ????? ????????
- AutoEventWireup
- Culture ???????, ????? ?? ???????? ???
?????????? ?? ?????????? - UICulture ???????, ???????? ?????????????? ??
??????? - Debug ???? ???? ???????? ? ??????????? ? debug
??????? - EnableSessionState???? ?? ?? ???????? ???????
- EnableViewState - ???? ?? ?? ???????? "view
state" - ErrorPage ????????, ??? ????? ?? ?? ??????????
? ?????? ?? ???????????? ??????????
35???????? ?? lt_at_Page gt
Language ???????? ?????????? ????, ?? ????? ???????? ? ??? ??????? ?? ???? ????????????? vb, c, JScript
Codebehind ???? code-behind ?????, ?????? ? ???????? ?? ??? ???????. Visual Studio ?????? ??????? code-behindWebForm1.aspx.cs (.aspx.vb)
Smart-Navigation ????????? ?? ?? ????????? ???? ??????????? ???? ?? ??????????. ???????? ?? ?? Internet Explorer 5 ??? ??-???
36ltformgt
- ???????? ??? ?????????? ?? ?? ?????????
- ? ???? ??? ????? ???? ?? ??? ??????? ltformgt ????,
?? ???? ???? server-side ltformgt ???
HTML ???????? ltformgtlt/formgt ltformgtlt/formgt ltformgt
lt/formgt
ASP.NET ???????? (???? 1) ltform
runat"server"gtlt/formgt ltformgtlt/formgt ltformgtlt/fo
rmgt
37???????? ?? ltformgt ????
id ????????????? ?? ???????
method ???????????? ?????? ?? ??????? ?? ?????????? ??????? ?? ???????GET ? URLPOST ? ?????? ?? HTTP ????????
runat ?????? ?? ??????? (parser), ?? ????? ?? ? HTML ???????, ? ASP.NET server control
38?????? WebForm1.aspx
lt_at_ Page language"c" Codebehind"WebForm1.aspx.c
s" AutoEventWireup"false" Inherits"WebApplicatio
n1.WebForm1" gt lt!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"gt lthtmlgt
ltheadgt lttitlegtWebForm1lt/titlegt ltmeta
name"GENERATOR" Content"Microsoft Visual
Studio 7.0"gt ltmeta name"CODE_LANGUAGE"
Content"C"gt ltmeta name"vs_defaultClientScri
pt" content"JavaScript"gt ltmeta
name"vs_targetSchema" content"http//schemas.mi
crosoft.com/intellisense/ie5"gt lt/headgt ltbody
MS_POSITIONING"GridLayout"gt ltform id"Form1"
method"post" runat"server"gt 'HTML and
controls go here lt/formgt lt/bodygt lt/htmlgt
39???????? ?????? ? ASP.NET
- Application (HttpApplication class)
- Session (HttpSession class)
- Request (HttpRequest class)
- Response (HttpResponse class)
- Server (HttpServerUtility class)
- Context (HttpContext class)
- Cache (System.Web.Caching.Cache class)
40???????? ????????
bool isSecureConnection Request.IsSecureConnec
tion Application.Add("key", "value") string
strEncoded Server.UrlEncode("???????") Respon
se.ContentType "text/html" Server.MapPath("img/
logo.gif") string imageFileName
Server.MapPath("img/logo.gif") Label1.Text
Server.HtmlEncode(str)
41???????????? ?? ??????
- Response.Redirect("Login.aspx")
- ???????????? ?? ?????? ?? ??????? (client
redirection) - ??????? ?????? ?? Web ????????
- Server.Forward("WebForm1.aspx")
- ???????????? ?? ?????? ?? ??????? (server
redirection) - ??????? ?????? ?? Web ????????
- ?? ???????? Web ????????? ?? ??????? ??
??????????????
42???????????? 2
43HTML escaping ????????
- ?????????
- string userName "\"ltscript language'JavaScript'
gtwhile(1) alert('bug!')lt/scriptgt" - TextBox1.Text userName
- ??????? ????
- Label1.Text userName
- ??? ???????? escaping ???????!
- ?????????
- Label1.Text Server.HtmlEncode( userName)
44???????????? 3
- ???????? ??? ?????????? ?? ????????? ?????
45?????????? - ????????
- ASP.NET Server Controls
- HTML server controls
- Web server controls
- ????????? ?? ????????
- ??? ???????? ?? ????????
- HTML server ????????
- Web server ????????
- ????????????? ????????
- ??????????
- ????????? ?? user ????????
- ?????????? ?? user ????????
- ????????? Web server ????????
- ???????? ???????? ltgt HTML
- ???????? ?? ?????????
- Rich controls
- List-bound controls
- ????????? ? ????? (DataBinding)
- ??? ?????? DataBind()
- DataBind()
46ASP.NET Server Controls (1)
- ??????????, ????? ?? ?????????? ?? ??????? ?
??????? UI - ???????? ??????, ???????? ?????, drop-down
???????, ... - ???? id ? text ????????, ????? ? runat"server"
??????? - ???????? ?? ?????????? ?? ????????? ?? ???????, ?
?? ??? ???????, ????? ? ??? HTML ??????????
47ASP.NET Server Controls (2)
48ASP.NET Server Controls
- ???????? ?? ????????? ?????, ????? ????????
??????? ???? ???????? - Event procedures ????????? ?? ???
?????????????? ?? ?????????? ? ??????????? - ???????????? ?????? ?????????? ???????? ? ???
??????? ? ???????? - Browser-specific HTML
- ?????????? ?????? ????? ? ????????? ? ???????
???????? HTML - ???????? client-side scripting
- ????? ?? ??
- HTML server controls
- Web server controls
49HTML server controls
- ??????????? ??????????? HTML ????????
- ???????????? HTML ???????? ?? ???????? ????
???????? ????? ? ?? ?? ???????? ?? ??????? - ??? HTML ??????? ?? ?????????? ?? HTML server
control, ??? ????? ???????? ?? ??????? ?? ????
?? ???????? ????? ?? ?????????? - ?????? ?? ???? ???????? runat"server"
- ?????? ?? ?? ??? ltform runat"server"gt...lt/formgt
????????? - ??????? ?? ? System.Web.UI.HtmlControls
50???????????? 4
51Web server controls (1)
- ????????? ????????? ???????? ?? ASP.NET
- ???????????????????? HTML????????
- ??? ???????????????(????. Calendar)
- ????????? ?? ????? ?? ??????????? ?? ??????????
?? HTML - ?????? ?? ????? ???? ASP.NET HTML
52Web server controls (2)
- ????????? ????????? ???????? ?? ASP.NET
- ???????????????????? HTML????????
- ??? ???????????????(????. Calendar)
- ????????? ?? ????? ?? ??????????? ?? ??????????
?? HTML - ?????? ?? ????? ???? ASP.NET HTML
53Web server controls (3)
- ????????? ????????? ???????? ?? ASP.NET
- ???????????????????? HTML????????
- ??? ???????????????(????. Calendar)
- ????????? ?? ????? ?? ??????????? ?? ??????????
?? HTML - ?????? ?? ????? ???? ASP.NET HTML
54Web server controls (4)
- ????????? ????????? ???????? ?? ASP.NET
- ???????????????????? HTML????????
- ??? ???????????????(????. Calendar)
- ????????? ?? ????? ?? ??????????? ?? ??????????
?? HTML - ?????? ?? ????? ???? ASP.NET HTML
ltinput type"text" runat"server"gt ltasptextbox
id"myTxt" runat"server"gt
55Web server controls (1)
ltaspButton id"MyBtn" runat"server"gt ltaspCalend
ar id"MyCal" runat"server"gt ltaspTextBox
id"MyTxt" runat"server"gt
- ???????? ?? ?? ??? ?????
- ltaspControlType...gt
- ???? id ???????
- ???? ?? ??????? ??? runat"server"
- ??????? ? ?????????????? System.Web.UI.WebControls
56Web server controls (2)
ltaspButton id"MyBtn" runat"server"gt ltaspCalend
ar id"MyCal" runat"server"gt ltaspTextBox
id"MyTxt" runat"server"gt
- ???????? ?? ?? ??? ?????
- ltaspControlType...gt
- ???? id ???????
- ???? ?? ??????? ??? runat"server"
- ??????? ? ?????????????? System.Web.UI.WebControls
57Web server controls (3)
ltaspButton id"MyBtn" runat"server"gt ltaspCalend
ar id"MyCal" runat"server"gt ltaspTextBox
id"MyTxt" runat"server"gt
- ???????? ?? ?? ??? ?????
- ltaspControlType...gt
- ???? id ???????
- ???? ?? ??????? ??? runat"server"
- ??????? ? ?????????????? System.Web.UI.WebControls
58Web server controls (4)
ltaspButton id"MyBtn" runat"server"gt ltaspCalend
ar id"MyCal" runat"server"gt ltaspTextBox
id"MyTxt" runat"server"gt
- ???????? ?? ?? ??? ?????
- ltaspControlType...gt
- ???? id ???????
- ???? ?? ??????? ??? runat"server"
- ??????? ? ?????????????? System.Web.UI.WebControls
59????????? ?? ????????
ltform runat"server"gt ltaspDropDownList
id"lstOccupation" AutoPostBack"true"
runat"server"gt ltaspListItemgtPMlt/aspListItem
gt ltaspListItemgtTesterlt/aspListItemgt
ltaspListItemgtUserlt/aspListItemgt
lt/aspDropDownListgt ltpgtYou selected
ltaspLabel id"lblSelectedValue" Text"lt
lstOccupation.SelectedItem.Text gt"
runat"server" /gt lt/pgt lt/formgt
60??? ???????? ?? ????????
- ?????? ?? ???????? ASP.NET ????????, ???
?????????? ?? ?? ????????? HTML server ????????
??? Web server ???????? - ????? ?? ?? ??????? ???????????????, ???????? ??
????? ????????? ?? HTML ???????? ??? ASP.NET
???????? - ???-??????? ???????? ? ?? ?? ???????? HTML server
?????????? - Web server ?????????? ?? ? ?????? ??????????? ?
???? ??-????? ??????? ????? ?? HTML server
??????????
61HTML server ????????
- ??????????? ??, ???
- ???????????? HTML-??????? ??????? ?????
- ???? ????? ????????? ???? HTML
- ???? server-side ??????????????
- ???????? ??? ???????????? HTML ????????
- ?????? ????? ?? ?? ???????? ???????????????? ??
??? ??????? - ?????????? ?????? ?? ?????????? ????????????
client-side ? server-side ?????? - ????????? ?? ???????? (bandwidth) ? ??????????
- ??? ??????? ???? ?? ?? ??????????, ???? ????
??????? ???????? ?? ???????? ????????
62Web server ???????? (1)
- ASP.NET Web server ?????????? ???????? ????? ????
???? ????????, ????? ????? ?????? ? HTML - ??????????? ??, ???
- ???????????? ???????????? ????? ?? .NET ??
?????? ?? - ????????? ?????????? ? ??????? ????????
- ??????????? ????????? ?? ???? ????????? ??
????????
63 Web server ???????? (2)
- ??????????? ??, ???
- ????????? Web ????????, ????? ?? ?? ?????????? ??
???????? ???????? - ????? ????? ?? ?????????? ?????????????? ????
???????? ???????? ??? ?????? - ? ???????? ??? ????????? ???????????? ?? Web
server ????????, ????? ??????? ?????????? ??????? - ?????? ??????????? ?? ????????? ?? ????????
(bandwidth)
64????????????? ???????? (1)
- ????????????? ?????????? ????????
- ? ASP.NET ????????, ????? ???? ?? ?? ?????? ?
????? ASP.NET ??? ????? - ? ???????? ?????????, ????? ????????
????????????? ????????? (UI) ? ?????????????? ???
???? - ???? ?? ?? ??????? ????? ?????????? ?? ???? ?
???? ?????????? - ?? ???? ?? ???? ??????? ???????? ?? ???????
- ??? code-behind ????
65????????????? ???????? (2)
- ????????????? ?????????? ????????
- ? ???????? ?? ?????????? ???????? (custom server
controls) - ?? ?????? ?? HTML ? ????????? ???
- ?? ??????? ltHEADgt, ltBODYgt ? ltFORMgt HTML ??????
- _at_Control ?????? _at_Page
- _at_Control ?? ???????? ???????? Trace, ??? ??????
?? ?? ?????? ? _at_Page
66??????????
- ?????????????
- ??????????? ??????? ???????????? ?? ?????
(namespaces) ?? ???????????? - ?? ?? ????????? ??????? ??? ???????????? ?????? ?
???????? ?? ?????????? - ??????????????
- ??????????????? ???????? ????? ?? ?? ?????????
?????? ?? ?????? ?? ???? ????????, ??? ??
???????? ????????? ?? ???????? ? ?????? - ??????? ?????????
- ????? ?? ????? ???????? ?? ???????? ?????????
???? ?? ??????????? ? ??????????, ????? ??
??????????
67????????? ?? user ????????
- ??????????????? ???????? ????? ?? ?? ????????
????? ?????? ???????? ?? ??? ???????????? - ?? ????? ?? ?? ???????? ????? ???????? ???
?????????? - ???? ???????? copypaste "????????????" ?
- ???? ?????? ? ?? ?? ??????? Web custom ????????
- ??????????? ?? ?????? ? ????? ??-?????????,
?????? ?????? ?? ???? ?? ????
68?????????? ?? user ????????
- ??????????????? ???????? ???? ?? ?? ??????? ???
????? ASP.NET ??? ????? - ??????? ?? ?????? ??????? (host)
- ??????? ?????? ??????????, ???? ????????
??????????? _at_Register - validNum e ????? ?? ???????????
- Src ? ??? ?? ????? ?? ??????????
lt_at_ Register TagPrefix"demo" TagName"validNum"
Src"numberbox.ascx" gt
69???????????? 5
- ??? ????????????? ????????
70????????? Web server ????????
- ???????? ???????? (Intrinsic controls)
- ???????????? ?? ???????? HTML ????????
- ???????? ?? ????????? (Validation controls)
- ???????? ?? ????????????? ???????? ?????
- ????????? ???????? (Rich controls)
- AdRotator, Calendar
- List-bound ?????????? ????? ????????? ?? ????????
????? - ?????????? ?? ?????????, ??????????? ?? ??????,
????????? ? ??????? - Internet Explorer ??? ??????????
- MultiPage, TabStrip, Toolbar ? TreeView
71???????? ???????? ? HTML
ltaspbuttongt ltinput type"submit"gt
ltaspcheckboxgt ltinput type"checkbox"gt
ltasphyperlinkgt lta href"..."gtlt/agt
ltaspimagegt ltimg src"..."gt
ltaspimagebuttongt ltinput type"image"gt
ltasplinkButtongt
ltasplabelgt ltspangt lt/spangt
ltasplistboxgt ltselect size"5"gtlt/selectgt
ltasppanelgt ltdivgt lt/divgt
ltaspradiobuttongt ltinput type"radio"gt
ltasptablegt lttablegt lt/tablegt
ltasptextboxgt ltinput type"text"gt
72???????? ?? ?????????
- CompareValidator
- ?????? ?? ??????? ??? ?????????? ?? ?????
???????? ??? ?????????? ???????? - CustomValidator
- ?????? ?? ??????? ? ???????
- RangeValidator
- ?????? ?? ? ? ??????? ??????? (??????)
- RegularExpressionValidator
- ?????? ?? ???????? ?? ???????????? ??????
- RequiredFieldValidator
- ?????? ?? ? ????????, ???????? ?? ????????
- ValidationSummary
- ???? ?? ??????? ??????????? ?? ?????? ?? ??????
???????? ?? ?????????
73Rich controls
- Rich controls ?? ?????????? ????????, ?????
??????? ??????, ?? ?????????? ? ????? ???????
?????? - AdRotator
- ??????? ???????????????? (????????????? ???
???????? ??????????) ?? ??????????? (???-????? ??
???????? ?? ??????) - Calendar
- ?????????? ???????????? ????????
74List-bound controls
- ???????? ????? ?? ???????? (???-????? ???? ??
?????) - CheckBoxList ?????? ?? check boxes
- Repeater ??????? ????????????? ????????? ??????
- DataList ??????? ?? Repeater, ?? ? ??????
??????????? ? layout ????? - DataGrid ??????? ????? ? ???????? ???
- DropDownList ??????? ????? ???? ????? ??????
(drop-down) - Listbox ??????? ?????? ?? ???????? ? ???????
- RadioButtonList ?????? ?? ?????? ??
???????????? ????? (radio buttons)
75????????? ? ????? (DataBinding)
- ASP.NET ???????? ??? ???????????? ????????? ??
????????? ? ????? (data binding) - ?????????? ?????????? lt... gt
//??? ???????? Customer lt custID gt //?
???????? Orders ltaspListBox id"ListCountries"
datasource'lt myArray gt' runat"server"gt //?
????? Contact lt ( customer.First Name " "
customer.LastName ) gt //? ???????? ??
????? Outstanding Balance lt GetBalance(custID)
gt
76??? ?????? DataBind()
- ??????? ?? ???????? ??????? ?? ltResponse.Write
gt, ???????? ????????? ? ???????? - Response.Write() ?? ??????? (?????????), ??????
?????????? ?? ????????? - ASP.NET-???? ????????? ?? ????????? ? ????? ??
??????? ??? ??????????? ?? ?????? DataBind() - ??? ??????? ?? ?? ??????, ?????? lt... gt
?????? ?? ?? ???????
77DataBind()
- DataBind() ? ????? ?? Page ? ?? ?????? ??????
???????? - DataBind() ?? ??????? ???????? ? ?? ??????
???-???????? ? ??????????? - ??????????? ?? DataBind() ?? ????????? ?????
Page ??????????? ??????????? ?? ?????? ??????
(lt... gt) ?? ????????? ? ????? - ???-????? DataBind() ?? ??????? ?? Page_Load
?????????
void Page_Load(Object sender, EventArgs e)
Page.DataBind()
78???????????? 6
79?????????? - Code Behind
- ???????? ?? ???
- ?????? Inline code method
- Code-behind
- ??? ?????? code-behind
- JIT ??????????
80???????? ?? ??? (1)
- ?????????? ?? ??? ? ASP.NET ??? ????? ????? ??
???? ?? ??? ?????? - Mixed code method
- ????? ? ? ????? ????, ? ????? ? ? ???
????????????, ?????? ? HTML ???? - ???? ????? ? ???-????????????????, ?????? ?????
?? ???? ? ???????? ?????? - Inline code method
- Code-behind method
81???????? ?? ??? (2)
- ?????????? ?? ??? ? ASP.NET ??? ????? ????? ??
???? ?? ??? ?????? - Mixed code method
- Inline code method
- ????? ? ??????? ? ??????? SCRIPT ?????? ? ?????
???? - Code-behind method
82???????? ?? ??? (3)
- ?????????? ?? ??? ? ASP.NET ??? ????? ????? ??
???? ?? ??? ?????? - Mixed code method
- Inline code method
- Code-behind method
- ????? ? ? code-behind ???????? ??????? ???? ??
???? ?? HTML ???????????? - ?????? ?????????? Visual Studio .NET, ???? ?
??????? ?? ????????????
83???????? ?? ??? (4)
84?????? Inline code method
lthtmlgt ltaspButton id"btn" runat"server"/gt ...
lt/htmlgt ltscript Language"c" runat"server"gt pr
ivate void btn_Click(object sender,
System.EventArgs e) ... lt/scriptgt
85Code-behind (1)
- ??????? ?????????? ????, ????? ???????
??????????? ?????? ?? ?????????? - ????? ??? ???????? ??? ????????? code-behind
???????? - ??? ?????? ??? ???? ??? ??????????, ? ????? ?
?????????? - ???????????? ?? ????? ? .aspx.vb ??? .aspx.cs
- ????? ????? ???????? ???? ????, ?????? ???
???????????? ?? ????????
86Code-behind (2)
87??? ?????? code-behind (1)
- ?? ?? ???????? ???? .aspx ???????? ? ??????
code-behind ????, VS.NET ?????? ??? ???????? ???
_at_Page ??????????? - Inherits ????????? ?? .aspx ?????????? ??
????????? code-behind ????? - Codebehind ???????? ?? ???????? ?? Visual
Studio .NET, ?? ?? ???????? ????????? - Src ??????? ????? ?? code-behind ??????????
???????? ??, ??? ??? ???????????? ?? ?
??????????????
lt_at_ Page Language"c" Inherits"MyProject.WebFo
rm1" Codebehind"WebForm1.aspx.cs" Src"WebForm1
.aspx.cs" gt
88??? ?????? code-behind (2)
- ?? ?? ???????? ???? .aspx ???????? ? ??????
code-behind ????, VS.NET ?????? ??? ???????? ???
_at_Page ??????????? - Inherits ????????? ?? .aspx ?????????? ??
????????? code-behind ????? - Codebehind ???????? ?? ???????? ?? Visual
Studio .NET, ?? ?? ???????? ????????? - Src ??????? ????? ?? code-behind ??????????
???????? ??, ??? ??? ???????????? ?? ?
??????????????
lt_at_ Page Language"c" Inherits"MyProject.WebFo
rm1" Codebehind"WebForm1.aspx.cs" Src"WebForm1
.aspx.cs" gt
89??? ?????? code-behind (3)
- ?? ?? ???????? ???? .aspx ???????? ? ??????
code-behind ????, VS.NET ?????? ??? ???????? ???
_at_Page ??????????? - Inherits ????????? ?? .aspx ?????????? ??
????????? code-behind ????? - Codebehind ???????? ?? ???????? ?? Visual
Studio .NET, ?? ?? ???????? ????????? - Src ??????? ????? ?? code-behind ??????????
???????? ??, ??? ??? ???????????? ?? ?
??????????????
lt_at_ Page Language"c" Inherits"MyProject.WebFo
rm1" Codebehind"WebForm1.aspx.cs" Src"WebForm1
.aspx.cs" gt
90??? ?????? code-behind (4)
- ?? ?? ???????? ???? .aspx ???????? ? ??????
code-behind ????, VS.NET ?????? ??? ???????? ???
_at_Page ??????????? - Inherits ????????? ?? .aspx ?????????? ??
????????? code-behind ????? - Codebehind ???????? ?? ???????? ?? Visual
Studio .NET, ?? ?? ???????? ????????? - Src ??????? ????? ?? code-behind ??????????
???????? ??, ??? ??? ???????????? ?? ?
??????????????
lt_at_ Page Language"c" Inherits"MyProject.WebFo
rm1" Codebehind"WebForm1.aspx.cs" Src"WebForm1
.aspx.cs" gt
91JIT ??????????
- Code-behind ?????????? ???? ?? ???? ???
??????????????, ??? ?? ???? just-in-time (JIT)
??????????? - JIT ????????????
- ? ?????????? ??? ????? ??????
- ?? ?????? ??? Src ???????? ?? _at_Page ???????????
- VS.NET ?? ?? ?????? ?? ????????????
- ????????????????
- ???????? ?????????? ??? ????? ??????
- ????????? ????????????? ?? ??? ????????????
(deployment) - ?? ? ????? ???? ???? ?? code-behind ?????
92?????????? - ???????
- ?????????? ?? ???????
- AutoEventWireup
- ????????????
- ?????? ????? ?? ASP.NET ??????????
- Page.IsPostBack
- AutoPostBack
93?????????? ?? ???????
- WebForm1.aspx
- WebForm1.aspx.cs
ltform id"form1" method"post" runat"server"gt
ltaspButton id"Cmd1" runat"server"/gt lt/formgt
... protected System.Web.UI.WebControls.Button
Cmd1 ... private void Cmd1_Click( object
sender, System.EventArgs e) // processing goes
here
94AutoEventWireup
- ?????? ???? ????????? ??????????? ?? ??????? ???
?????????? - ??? ? true, ???????? ??? ? ???????
- ??? ?????????????????? ? ?? ????? ?????, ??
?????????? ?? ?? ?? ???????? ??????????? ????????
this.Init new System.EventHandler(this.Page_I
nit) this.Load new System.EventHandler(this.
Page_Load)
95???????????? 7
- ??????? (AutoEventWireup)
96?????? ????? ?? ASP.NET ??????????
- ????? ?? ??????? ??? ????? ?????? ?? ASP.NET
???????? - Page_Init ???????????? ??????????, ????
???????????? Web server ?????????? - Page_Load ??????? ??, ?????? ?????????? ??
?????? ?? ?????? - ??????? ?? ?????????? ?????? ?????? ??
code-behind ??????????, ????? ?? ????????
???????? ?? ?????????? (Button1_Click,
TextBox1_Changed) - Page_Unload ??? ??????????? ?? ????????????
(render) ?? ?????????? - ???????? ?? ?? ????????????? ?? ???????
97Page.IsPostBack
- ? ASP.NET ???????????????? ?? ??????? ? ?? ??????
?????????? ??????? ??? ??????? ?? ????????? - ???????? ?? ?????? postback
- ?????????? Page.IsPostBack ????? ???? ??????????
?? ??????? ?? ????? ??? - Page.IsPostBack ? false, ??? ?????????? ??
??????? ?? ????? ??? - Page.IsPostBack ? true, ??? ???????? ?
???????????? ?? ???????? ?? ??????????
98Page.IsPostBack
private void Page_Load(object sender, System.Even
tArgs e) if (!Page.IsPostBack) //
executes only on initial page load // i.e.
initialize controls // executes on every
request // controls are already initialized
99AutoPostBack (1)
- ??????????, ????? ????????? ?????????? ?? ??
????? ?? ??????? ?? ??????????? - ?????????? ??????, ?? ??? ?????? ???????
?????????? ?????? ?? ?? ????? ?? ??????? ? ?? ??
??????? ???, ????????? ?? ???? ??????? - ?????? ?? ? ???????? AutoPostBack ?? ???????????
???????? - ???? ?? ?????? ???????, ? ????? ? ??????????
??????????, ???? ?? ?? ??????? ????????? (submit)
?? ??????????
100AutoPostBack (2)
- ??? ??????? ?? ???? ???????? AutoPostBacktrue,
?? ?? ??????? ??? ????? ??????? - ???????? ????? DropDownList ? AutoPostBacktrue
- ?????? ??? ????? ??????? ?? ?????? ? ???? ??????
?????? ???????? ?? ??????? ?? ??????? ???
???????? ???? ? ???????? ????? - ??????? ? ????????? ?????? ?? ??????? ??? ?????
???????
101AutoPostBack (3)
- WebForm1.aspx
- WebForm1.aspx.cs
ltaspDropDownList id"ListBox1" runat"server"
AutoPostBack"True"gt ltaspListItemgtFirst
Choicelt/aspListItemgt ltaspListItemgtSecond
Choicelt/aspListItemgt lt/aspDropDownListgt
private void ListBox1_SelectedIndexChanged (objec
t sender, System.EventArgs e) TextBox1.Text
ListBox1.SelectedItem.Value
102?????????? ???????????? ? ?????????
- Runtime ??????????
- ???????????? (Trace)
- Page vs. Application Level Tracing
- ????????? ?? ????????????
- Trace ??????
- ????????? ????? ?? ??????????????
- ????????? ?? ??????????????
- ????????? pageOutput
- trace.axd
- ???????????? ? ????????????? ?????????
- Debug
- Remote debugging
103Runtime ??????????
- ?????? ??? ???????????? ??????, ?????? ??
???????? ??????????, ???? ?????????? Debug ?
Trace ???????? - ?????? ??
- ????????? ????????? ?? ??????????
- ????????? ???? ?????????? ?????????? ?? ?????????
- Trace.WriteIf(), - ???????? ???? ?? ?????????? ?? ????????????
- ???????? ??????????? ?????? ?? ?????? ??? ?????,
?????? ???????????? ?? ?????????
104???????????? (Trace)
- ???? ?? ??????? ?????????? ?? ???????????? ??
?????? ??? ???????? ?? ?????????? ????? - ???? ?? ??????? ???????????? ? ??????? ? ?? ?
??????? ??? ????????? (??? logging) - ??????? ?? ? ?? ????? ??????????????
- ?? web.config
- ???? ?? ?? ????? ? ????? ?? ????? ????????
?????????
105Page vs. Application Level Tracing
- ?? ??????? ???????? (Page-level tracing)
- ?????? ?? ?? ????? ???????? ?????????
- ?????? ?? ????????? ? ???????????? ?? ??????????
- ???????????? ?? ???? ?????????? (Application-leve
l tracing) - ????? ?? ?? Web.config ?????
- ???? ??????????? ?? ?????????????? ?? ?? ????? ?
??????? - ???? ?? ?? ???????? ???? ???????????? ??
????????? ???????? trace.axd
106????????? ?? ???????????? (1)
- ??? ??????? ????????? (??????) ?? ??????????,
????? ?? ???????? ? Trace - Request Details ?????????? ?? ????????
- ????????????? ?? ??????? (ID), ????? ?? ????????,
??? ?? ???????? ? ?????? ?? ????????
107????????? ?? ???????????? (2)
- Trace Information ????? (Output) ?? ??????????
? ????????????? ?????????? trace ????????? - Control Tree ?????? ????????
- Cookies Collection ?????? ?? ?????? ??????????
?????? - Headers Collection
- Form Collection ?????? ?? ?????????? ? ???????
????????? ??? ??????? (ltform runat"server"gt...) - Server Variables ?????? ?? ?????? ????????
?????????? ? ??????? ?????????.
108Trace ??????
- Trace.Write(...) ? Trace.Warn(...)
- ????? ?? ?? ????????? ?? ????????? ??
???????????? ?? ???????????? ?????????? ???
???????????? - ???????? ???????????? ? Trace Information
???????? - ????? ?????? ??????? ?? ??????? ?????
- ???????????? ??????? ?, ?? Trace.Warn() ???????
??????????? ? ???????
109????????? ????? ?? ??????????????
- ???? ?? ?? ??????? ???? ?????????????? ? ???????
??? ?????????? Trace.IsEnabled - ? ???? ???????? ???? ????????? ?? ??
???????/???????? ??????????????Trace.IsEnabled
false - ?????????? ??? ??-?????? ???? ?? ?????????? ??
???????????? ?? ???? ??????????
110????????? ?? ??????????????
- ???? ?????? ???? ?????? tracing ?? ????
??????????, ??????????? ?? ????????- ???? ?? ????
???????? ?? ????????
?? ???? ???????? ?? ???? ?????????? ???????? ?? ??????????? ????????
TraceTrue TraceTrue ??? TraceFalse ??? ???????????? (trace)
TraceFalse TraceTrue ??? TraceFalse ???? ???????????? (trace)
?? ? ??????? TraceTrue ??? ???????????? (trace)
?? ? ??????? TraceFalse ???? ???????????? (trace)
111????????? pageOutput
- ????????? pageOutput ?? ???????? trace ??? ?????
Web.config ?????? ???? ?? ?? ???????? ???????????
?? ?????????????? - true - ??????????? ?? ???????? ?? ?????? ????????
???? ???? ?? ???????????? ? (??????? ?? ??????) - false - ??????????? ?? ???????? ? ???????
ltconfigurationgt ltsystem.webgt lttrace
enabled"true" pageOutput"false"/gt lt/system.w
ebgtlt/configurationgt
112trace.axd
- ???????????? ?? ?????????????? ?? ???? ??????????
???? ?? ?? ??????? ? ??????? - ???? ?? ???? ??????, ???? ?? ???????? ?????????
????????, ????? ? ???????? ?? ???????????? ???
????? ??? ?????????? - ??????? ?? ?????????? ?http//??????/??????/trac
e.axd - ?????? ??????? ???????? ??? ???????????, ???? ??
???? ??????
machine.config lthttpHandlersgt ltadd verb""
path"trace.axd" type"System.Web.Handlers.TraceH
andler"/gtlt/httpHandlersgt
113trace.axd
- ???????????? ?? ?????????????? ?? ???? ??????????
???? ?? ?? ??????? ? ??????? - ???? ?? ???? ?????? ???? ?? ???????? ?????????
????????, ????? ? ???????? ?? ???????????? ???
????? ??? ?????????? - ??????? ?? ?????????? ?http//??????/??????/trac
e.axd - ?????? ??????? ???????? ??? ???????????, ???? ??
???? ??????
machine.config lthttpHandlersgt ltadd verb""
path"" type"System.Web.Handlers.TraceHandler"/gt
lt/httpHandlersgt
114???????????? 6
115???????????? ? ????????????? ????????? (1)
- ? ????????????? ????????? ????????? ????? ?? ??
????????? ???????? ?? ????????????(
Trace.Write(), Trace.Warn(), ... ) ?? ????
????????? - ????????? ?? ?? ????????? ????????? ?? ???
??????? ? ?? ?????????? - ??????????? ?? ???????? ?? ??????????, ? ????? ?
??????????
116???????????? ? ????????????? ????????? (2)
- ????????? ?? ???????????? ?? ?????????
? ????????? ?? ?????????? ????????
???????? ? ???????????? ????????? ?????????????? ? ???????? ?? ?????? ??????
???????? ? ????? ????????? ?????????????? ? ????????, ???? ?????? ?? ??????? ??????????? ?????
????????? ? ??????????? ???????? ?????????????? ? ????????? ?? ?????? ??????
????????? ? ????? ???????? ?????????????? ? ????????, ???? ?????? ?? ???????? ?????? ?? ??????????
117Debug
- ???????????, ????? ????????? Debug ??????, ?? ??
????????, ???? ??? ???????????? ? ??????????? ?
debug ????? - ????? ???????????? ??-????????, ?????? ????? ??
?? ??????? - ???? ????????? ?????? ?? ??
?????????? ? release ????? - ?????? ?? ? System.Diagnostics
118Remote debugging
- ???????????? ????????? ? ????????? ?? ??????????
?? ????????? ?????? - ????????? ????????? ?? ?????????? ?? ?????????
??????? ?? ???? ??????? ??????? - ??? ?? ??????? ??????????
- ???????? ?? Visual Studio .NET ?? ???????????
??????. - File ? Open ? Project From Web
- ? Open Project From Web ??????????? ??????? ??
???? ??????? (URL) ?? ??????? - ? Open Project ??????????? ??????? ?? ??????
???????? ?? ??????????? ?????? - ???? ???? ?? ?????? ????????, ???? ?? ??
????????? breakpoints ??? ???? ???????????? ?
???????
119?????????? - ?????????
- ???????? ?? ?????????
- ????????? ?? ???????
- ?????????? ?? ???????? ?????
- ???????? ?? ?????????
- ??????????
- ???? ?? ???????? ????????????
- ???? ????????
- ?????????? Type
- Spoofing/Malicious code
- ErrorMessage
- ?????????? Display
- ??????????? ?? ???????? ?? ?????????
- ????????? ?? ??? ????????
120????????? ?? ???????
- ?????? ???????????? ??????? ?????, ???????????? ?
???? ????????? ?? ???? ?? ??????? - ?????? ?????? ????? (???? ???????) ?? ???????
???????????, ? ????? ???? ?? "??????"
???????????? - ???????????? ?? ? ?????????? ?????????, ?????? ??
????????? ????????? ??? ?????? ?? ??????
?????????? ?? ???????? ?????
121?????????? ?? ???????? ?????
- ???????? ?? ???????? ???? ?????????????
?????????? ????? ????????? ?? ?????????????
??????? ?????? ?????? - ????, ????? ?? ?????????, ???????????? ?????????
?? ?????? - ??? ??????? ????? ?? ?? ?????????, ??????
???????? ?? ???? ????????? - ????????????? ?????? ???????
- ???????? ??????? ???? ?????, ?????????? ?? ?????,
?????? ?? ????????? ????????? ??? ?????????????
???????
122???????? ?? ????????? (1)
- ASP.NET ???????? ?????????? ??????? ?? ?????????,
???? ?????????? ?????? ???????? ?? ????????? - CompareValidator
- ???????? ???????? ????? ?? ???? ???????? ?
???????? ????? ?? ????? ???????? ??? ??????????
????? - ?????? - ?????? ???????? ?????? ?? ?? ?????? ???
????
123???????? ?? ????????? (2)
- CustomValidator
- ?????????? ????? ?? ????????? ?? ????????? ??????
?? ????????? - ???????????? ?????? ?? ?????? ???????? ??
?????????? - RangeValidator
- ????????? ???? ?????? ?? ???? ???????? ? ?????
??? ?????????? ?????????, ??? ????? ???
?????????, ???????? ? ????? ????????
124?????????? (1)
- RegularExpressionValidator
- ????????? ???? ???????? ????? ????????? ??
????????????? ??????? ?????? - ???????? ? ?????? ? ????????? ?????
- ??????? ?? ???????? ?? ???, e-mail ??????,
???????? - Visual Studio .NET ?????????? ????? ??????? ??
???????? ?? ???-?????????? ??????? ?????
125?????????? (2)
- RequiredFieldValidator
- ????????? ???? ?? ???????? ??????? ????? ?
??????????, ????? ????????? - ????????????, ????? ??????? ??????? ???????? ?? ?
???????? - ?????? ???????? ???????? ??????? ?? ???????
????????, ????? ???? ???????? ??????? ????? - ValidationSummary
- ???????? ?????? ?????? ?? ?????? ???????? ??
????????? ?? ?????????? - ??????? ?? ???-????? ?? ?????? ?? ?????????????
126???? ?? ???????? ????????????
- ?????????? ?? ???????? ?? ???????
- ??????
- ???? ?? ??? ???????? ? ??? ???????
- ??? ???????? ???? ??? ????????? ??? ??????? ???
??, ????????? ???????????? ?? ???????? ?? ??????? - ?????????? ?????????? ???? ?? ???????
????????????, ?????????? ??? ???????
127???? ????????
- EnableClientScript
- ?????? ???? ?? ??? ???, ????? ?? ????????
???????????? ??? ??????? - ?? ???????????? ? true
- ?????? ???????? ? ?? ???????
- ?????? ????????? ?? ??????? ?? ????????? ?
???????? ?????????, ????? ?? ?? ?????? ?????
??????? ??? ??????????????? - ControlToValidate
- ?????? ??? ????????, ???????? ???? ??
???????????, ?? ?? ????????
128?????????? Type
- RangeValidator ? CompareValidator ???? ????????
Type - ????? ?????? ???? ?? ???????????? ?????
- Visual Studio .NET ??????????? ?? ??????? ????
???????? ??? ???????? ?? ???????? ?? ??????????
ControlToValidate - ???????? ????????? ?? String, Integer, Double,
Date ? Currency
129?????? ?????????
- ???? ???? ?????????? ?? ????????? ? ????
????????? ?? ??????????, ?? ??????? ??????????? ? - ????? ?? ?????????, ????????? ?? ??????, ????????
?????????
ltasptype_of_validator id"validator_id" runat"
server" ControlToValidate"control_id" ErrorMess
age"error_message_for_summary" Display"staticd
ynamicnone" Text"Text_to_display_by_input_contr
ol"gt lt/asptype_of_validatorgt
130Spoofing/Malicious code (1)
- Spoofing ?? ?????? ?????, ??? ????? ????????????
?????????? HTML ??????????, ????? ? ????????? ??
???? - ????? ?????????, ??? ???? ? ????? ???????? ?????
?? ??????????? - ??????????? ? ????????? ?? spoofing, ???? ??????
?? ????? ?? ??????????? ?????? - ???????????? ???? ??????? ???? ?? ?????????
- ? ASP.NET ??????????? (????? ?? ???????) ??????
?? ??????? ? ?? ??????? - ??? ???????????? ?? ???? ?????????? ???? ??? ??
??????? ?????????
131Spoofing/Malicious code (2)
- ?????????? ???
- ?????? ?????????? ???? ?? ?????? ???????????
????? ? ??? ???????? ???? ???????? ?? ??????
?????, ????? ?? ?? ????????? - ???? ?? ??????? ??????? ?? ???????????? ??
???????????, ??????????? ?? SQL ??????,
?????????? ?? ???????????? ?? ???? ?? ?????
132ErrorMessage
- ErrorMessage
- ?????????, ????? ?? ???????, ?????? ? ???????????
?????????? ?? ????????? - ??? ?????????? Text ? ????????, ?? ???????
???????? ????? - ?????? ??? ValidationSummary ????????
- ??????? ?? ?????????? Text ?? ??????? ?? ???????
?? ?????????? ?? ????????? - ??????? ?? ?????????? ErrorMessage ?? ??????? ?
?????????? ValidationSummary
133?????????? Display
- ?????? ???????????? ????? ??????? ???????? ??
????????? - ?????? ??? ??????? ? ? FlowLayout
- ????? ?? ?????????, ????? ?? ???????? ?? ???????
?? ?????????? ?? ????????? - ???????????, ????? ?? ???????? ???
ValidationSummary ??????????, ?? ?? ?????? ??
?????????? Display - ???????? ?? ???????? ?????????
- Static - ???????? ????????? ????? ?? ????????
- Dynamic - ?????? ????? ?? ?? ?????, ?????? ????
?????? - None - ??????? ??????????? ?? ????????? ?? ??????
134??????????? ?? ???????? ?? ?????????
ltaspTextBox id"txtPhone1" runat"server"gt lt/asp
TextBoxgt ltaspRequiredFieldValidator id"Required
txtPhone1Validator1" runat"server" ErrorMessage
"A telephone number is required" ControlToValida
te"txtPhone1" Text""gt lt/aspRequiredFieldValid
atorgt ltaspRegularExpressionValidator id"Regular
txtPhone1Validator1" runat"server" ErrorMessage
"Tel.no. is not formatted correctly" ControlToVa
lidate"txtPhone1" ValidationExpression "((\(\
d3\) ?)(\d3-))?\d3-\d4" Text""gt lt/asp
RegularExpressionValidatorgt
135????????? ?? ??? ????????
- ?????????? Page.IsValid ?? ?????????, ???? ??
????? ????????? "?" ?? ?????? ???????? ??
????????? ?? ??????????
private void CmdSubmit_Click(object
s, System.EventArgs e) if (Page.IsValid)
Message.Text "Page is Valid!" // Perform
some logic here // else ?????? ?? ? ?????
?????????? // ?? ?? ????? ?? ??????????? ?
???????? // ??????????? ?? ????? ????????
136???????????? 7
137?????????? - ???? ?? ?????
- ADO.NET
- ??????? ????? ?? ADO.NET
- .NET Data Provider Objects
- ADO.NET ??????
- System.Data.DataSet
- ???????? ?? ????????? ?? ?????
- ???? ?? ?????? ???????????
- ?????? ??????? ?? DataGrid
- ???? ????????
- ????????????
- Repeater
- ??? ?? ???????? Repeater
138ADO.NET
- ADO.NET ? ????? ?? ???????, ????? ?? ????????? ??
?????? ? ??????????? ?? ???? ?? ????? - ???????? ? ?? Microsoft ActiveX Data Objects
(ADO) - ??????????? ?? ?????? ? ????? ? ????????? ?????
(disconnected environment) - ADO.NET ???????? XML ???? ??????? ?? ???????????
?????, ???? ???????????? ??-?????? ???????????? ?
????????? ?? ADO - ?? ?????? ??????????? ?????????? ???????? ??
ADO.NET
139??????? ????? ?? ADO.NET
- DataSet
- ??????? ? ???? ?? ???? ??? ?????? DataTable
?????? - ????????? ????????? ?? ????????? ?? ?????? ??
????? - ????? DataTable ????? ???? ?? ?? "???????" ?
????? ?? ???????? ???????? - ????????? ?? ????? (.NET data provider)
- Connected model
- Disconnected model
140.NET Data Provider Objects
- SQL Server .NET Data Provider
- ?? ?????? ??? SQL Server 7.0 ??? ?? ????? ??????
- SqlConnection, SqlCommand, SqlDataReader ?
SqlDataAdapter - OLE DB .NET Data Provider
- ??? ????????? ?? ?????? ???????? ???? ?? ?????
- OleDbConnection, OleDbCommand, OleDbDataReader ?
OleDbDataAdapter
141ADO.NET ??????
- Connection
- ??????????? ?????? ? ?????? ?? ?????
- Command
- ?????????? ????? ?? ????????? ?? ??????? ??
?????? ?? ????? - DataReader
- ???? ?? ?????? ?? ????? ??? ??????? ?????.
??????? ?? ????? ?? ?? ???????? - DataAdapter
- ????? ?????? ????? DataSet ????? ? Connection
????? - ????? ?? ????????? ?? DataSet ?????? ?? ??
??????? ? ?????? ?? ?????
142System.Data.DataSet
- ???????????? ??? ?? ????? ? ???????
- ?????? ?????? ? Disconnected ?????? ?? ?????? ?
???? ?? ????? - ??????? ?? ????????? ?????????, ????? ? ??????
- ??? ????????? ????????????? ?? ???????, ???????,
?????? - ?? ?????? ?????????? ?????????? ???????? ??
ADO.NET
143???????? ?? ????????? ?? ?????
- ??????????, ????? ?? ???????? ? ???????? ??
?????, ?? ??????? list-bound controls - CheckboxList, DropDownList, ListBox,
RadioButtonList - DataList ??????? ??????? ? ???????????? ??????
- DataGrid ?????? ????????, ?? ?? ??????????
??-??????? - Repeater ??????? ??????? ? ??????, ????????? ??
???????????
144???? ?? ?????? ???????????
- ???-????? ? Page_Load() ??????
- ???? ??? ??????? ?? ? ? ????? PostBack
- ??? ????????? ?? ????? (??? ???????)
- ??????? ?? ???? ????????? ?????????????
- ??????????? ?? ?????? ??? ??????? ??? ???
????????? - ??????? ?? ????????
- ??????????? ???? ?? ????? ??? ????????? ??
??????????
145??????
SqlConnection connection new
SqlConnection("Serverlocalhost") SqlDataAdapte
r adapternew SqlDataAdapter() adapter.SelectComm
and new SqlCommand() adapter.SelectCommand.Conn
ectionconnection adapter.SelectCommand.CommandTe
xt "SELECT FROM customers" DataSet
dataSet new DataSet() adapter.Fill(dataSet,
"Customers") CustomersDataGrid.DataSource
dataSet CustomersDataGrid.DataMember
"Customers" CustomersDataGrid.DataBind()
146???? ????????
- ?? ?????? ??? DataSet, List-bound ??????????
????????? ?????????? - DataSource ?????? DataSet ??????
- DataMember ?????? DataTable ?????? ? DataSet
?????? - DataTextField ?????? ????????, ????? ?? ??
??????? - DataValueField ?????? ????????, ?? ????? ?? ??
??????? ?????????? ?? ?????? - ?????????? ??? ?? ???? ?? ListBox, DropDownList,
CheckBoxList ? RadioButtonList
147???????????? 8
148DataBinder.Eval()
ltaspDataGrid id"DataGrid1" gt ltColumnsgt
ltaspTemplateColumn HeaderText"Link"gt
ltItemTemplategt ltaspHyperLink Runat server
NavigateUrl 'ltGetURL(DataBinder.Eval(Containe
r.DataItem, "Link"))gt' gt ltDataBinder.Eval(C
ontainer.DataItem, "Link")gt
lt/aspHyperLinkgt lt/ItemTemplategt
lt/aspTemplateColumngt lt/aspDataGridgt
string GetURL(string str) if(
str.IndexOf("http//") ! -1 ) return str
return "http//" str
149Repeater
- ??? ?????? ?????? ?? ???????? ??????? ??
?????????? ? ?? ??????? ?? ?? ????????? ???
DataGrid ??? DataList ???? ?? ??????? - ?? ????????? HTML ??????? (lttablegt)
- ???? ????? ?????? (ltulgt, ltolgt) ?? ??? ??????????
? ???? ?????? - ??????? ?? ???? ???? ?? ????? ????????? ? for
????? ? ?????????? ??? ? HTML ? ??????????, ?????
?????????o ?? ? ????? ???? ?????? ?????????? - Repeater ?????????? ? ???-????????? ?? ?????,
?????? ??? ???? ?? ?????? HTML ???? ??
???????????? - ??? ???????? ?? ? ????????? ?????? ? ?? ?????? ??
??????????? ???????, ?? ??? ?????? ?? ?????????
???? ????????????, ???? ???????????? ?????? ??
???????? ???? ?????, ????????? ? Repeater
150??? ?? ????????
151Repeater ?????? (1)
ltaspRepeater id"myRepeaterPlain"
runat"server"gt ltItemTemplategt lt
DataBinder.Eval(Container.DataItem, "Id") gt,
lt DataBinder.Eval(Container.DataItem, "Name")
gt, lt DataBinder.Eval(Container.DataItem,
"URL") gt, lt DataBinder.Eval(Container.DataIte
m, "Image") gt ltbr /gt lt/ItemTemplategt lt/aspRep
eatergt
152Repeater ?????? (2)
ltaspRepeater id"myRepeaterUL" runat"server"gt
ltHeaderTemplategt ltulgt lt/HeaderTemplategt
ltItemTemplategt ltligt lta
href"ltDataBinder.Eval(
Container.DataItem,"URL") gt"gt lt
DataBinder.Eval(
Container.DataItem, "Name") gt lt/agt
lt/ligt lt/ItemTemplategt ltFooterTemplategt
lt/ulgt lt/FooterTemplategt lt/aspRepeatergt
153Repeater ?????? (3)
ltaspRepeater id"myRepeaterImage"
runat"server"gt ltItemTemplategt lta href"lt
DataBinder.Eval(Container.DataItem,
"URL") gt"gt ltimg
src"ltDataBinder.Eval(
Container.DataItem, "Image") gt"
border"0" alt"lt DataBinder.Eval(
Container.DataItem, "Name")
gt"/gt lt/agt lt/ItemTemplategt lt/aspRepeatergt
154?????????? - State Management
- State Management
- ????? ? ?????
- Server-side state management
- Application ???????
- Session ???????
- ?????????? ??????????
- ????????? (cookies)
- ?????????
- ???????? ?? ???????????
- ??? ?? ???????? ???????????
- ??? ?? ???? ?? ???????????
- _VIEWSTATE
- ?????????? ?? _VIEWSTATE
- ??????? _VIEWSTATE
155State Management (1)
- ??????, ??? ????? ????? ?????????? ???????? ??
??????? ?????????? ?? ??????? - ???? ?????????? ????????? ??? ????????? ??
???????? ????????? ?? ????????? - ????????? ?? ???????? ???????????? ??????????
- ????????? ?????? ?? ?????????? ????? ??????????
- ???????????? ?? ?????? ????????? ?? ??????????
(state)
156State Management (2)
- ?????, ????? ???? ?? ??? ??????? ????????
?????????, ?? ?????? stateful - ?????, ????? ???? ?????????, ?? ?????? stateless
- ???????? ??