From 14da58ad5da50d1b676ba898b2737266b317409e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 04:27:31 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2012?= =?UTF-8?q?=20=E5=91=A8=E6=B3=BD=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\347\254\224\350\256\260.md" | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 "12 \345\221\250\346\263\275\345\274\272/\347\254\224\350\256\260.md" diff --git "a/12 \345\221\250\346\263\275\345\274\272/\347\254\224\350\256\260.md" "b/12 \345\221\250\346\263\275\345\274\272/\347\254\224\350\256\260.md" deleted file mode 100644 index 4d7d034..0000000 --- "a/12 \345\221\250\346\263\275\345\274\272/\347\254\224\350\256\260.md" +++ /dev/null @@ -1,47 +0,0 @@ -静态网页: - 以.html 或者.htm 结尾的网页 - 只能单纯的显示文本和图像 - 无法和用户接互,无法根据用户的请求显示不同的网页内容 -服务器端开发技术: - 不仅可以显示文本和图像 - 还可以根据用户请求,动态显示不同的网页内容(与后台交互) - -C/S是Client/Server的缩写。服务器通常采用高性能的PC、工作站或小型机, -并采用大型数据库(“MySQL知识库”)系统,如Oracle、Sybase、InFORMix或 -SQL Server。客户端需要安装专用的客户端软件。 - -B/S是Browser/Server的缩写,客户机上只要安装一个浏览器(Browser), -如Netscape Navigator或Internet Explorer,服务器安装Oracle、Sybase、InFORMix或 - SQL Server等数据库。在这种结构下,用户界面完全通过WWW浏览器实现, -一部分事务逻辑在前端实现,但是主要事务逻辑在服务器端实现。 -浏览器通过Web Server 同数据库进行数据交互。 - -从前台接收数据到后台 -string uname = context.Request.Params["uname"] -DATA.LoginCheck lc = new DATA.LoginCheck(); - -public bool IsReusable //是否自动缓存 - -Page.PreviousPage != null - -Page.IsPostBack属性 确定页面是首次呈现还是响应回发 - -TextBox tname= (TextBox)PreviousPage.FindControl("TextBox1") - 控件值 控件 -读取信息 -String NameID = ViewState["nameID"].ToString(); - -PostBackUrl=“” 跳转 - -ASP.NET Web 运行原理 -{ UserLogin.aspx 可视化组件 -UserLogin.aspx.cs 编程逻辑(代码隐藏) } --->由.aspx与aspx.cs共同组成了 - Webform网站页面 Webform - - - - - - - -- Gitee From 48748d6242b205a2055d5ba5b18bee2acd20013b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 04:27:35 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2024?= =?UTF-8?q?=20=E9=99=88=E9=92=B0=E9=94=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71\350\261\241\347\254\224\350\256\260.md" | 175 ------------------ 1 file changed, 175 deletions(-) delete mode 100644 "24 \351\231\210\351\222\260\351\224\213/5.20 ASP\345\206\205\347\275\256\345\257\271\350\261\241\347\254\224\350\256\260.md" diff --git "a/24 \351\231\210\351\222\260\351\224\213/5.20 ASP\345\206\205\347\275\256\345\257\271\350\261\241\347\254\224\350\256\260.md" "b/24 \351\231\210\351\222\260\351\224\213/5.20 ASP\345\206\205\347\275\256\345\257\271\350\261\241\347\254\224\350\256\260.md" deleted file mode 100644 index bb53ad9..0000000 --- "a/24 \351\231\210\351\222\260\351\224\213/5.20 ASP\345\206\205\347\275\256\345\257\271\350\261\241\347\254\224\350\256\260.md" +++ /dev/null @@ -1,175 +0,0 @@ -``` -Transfer 鏂规硶鎶婁竴涓 ASP 鏂囦欢涓垱寤虹殑鎵鏈夌姸鎬佷俊鎭紙鎵鏈 application/session 鍙橀噺浠ュ強鎵鏈 request 闆嗗悎涓殑椤圭洰锛夊彂閫侊紙浼犺緭锛夊埌鍙︿竴涓 ASP 鏂囦欢涓 - -褰撶浜屼釜 ASP 瀹屾垚浠讳綍鏃讹紝瀹冧笉浼氳繑鍥炲埌绗竴涓 ASP 椤甸潰銆 - -娉ㄦ剰锛歍ransfer 鏂规硶鏄 Response.Redirect 鐨勪竴涓珮鏁堢殑鏇夸唬鏂规銆傚綋 Server.Transfer 鏂规硶鍦ㄦ湇鍔″櫒涓婂悜鍙﹀鐨 ASP 椤甸潰浼犺緭鎵ц鏃讹紝閲嶅畾鍚戝己鍒 Web 鏈嶅姟鍣ㄥ鐞嗛澶栫殑璇锋眰锛岄伩鍏嶄簡棰濆鐨勫懆鎶 - -鎶婄涓涓户鎵垮埌绗簩涓 -``` - -``` -Execute 鏂规硶浠庡彟澶栦竴涓 ASP 鏂囦欢涓墽琛 ASP 鏂囦欢銆傚湪琚皟鐢ㄧ殑 .asp 鏂囦欢鎵ц瀹屾瘯鍚庯紝鎺у埗鏉冧細杩斿洖鍘熷鐨 .asp 鏂囦欢銆 - -鎶婄浜屼釜杩斿洖鍒扮涓涓 -``` - -``` - -Request瀵硅薄 -Response瀵硅薄 -Server瀵硅薄 -ViewState瀵硅薄 -
-
-
- -
-
-protected void Page_Load(object sender, EventArgs e) -{ - //鍒濆鍖 - if(!IsPostBack) - { - ViewState["lbl1"] = 0; - } -} -//娌℃湁鎴愬憳鍙橀噺 -//HTTP鍗忚:鏃犵姸鎬 -protected void Button1_Click(object sender, EventArgs e) -{ - int c = (int)ViewState["lbl1"]; - c++; - lbl1.Text = c.ToString(); - ViewState["lbl1"] = c; -} -Request瀵硅薄 - QueryString(鏌ヨ瀛楃涓)锛氳幏鍙栭氳繃URL浼犻掕繃鏉ョ殑鏁版嵁 - Form(琛ㄥ崟鏁版嵁)锛氳幏鍙栭氳繃琛ㄥ崟鎻愪氦浼犺緭鐨勬暟鎹 - ServerVariables灞炴э細鑾峰彇Web鏈嶅姟鍣ㄥ彉閲忕殑闆嗗悎 - Params锛氫互涓婁笁绉嶆柟寮忎紶杈撶殑鍐呭閮藉彲浠ヤ娇鐢ㄨ灞炴ц幏鍙 -
-
- Page1 - 璺宠浆 -
-
-protected void Page_Load(object sender, EventArgs e) -{ - -} -
-
- Page2 -
-
-protected void Page_Load(object sender, EventArgs e) -{ - string name = Request.QueryString["name"]; - string c = Request.QueryString["class"]; - Response.Write($"name:{name}{c}鐝"); - string name1 = Request.Params["name"]; - string c1 = Request.Params["class"]; - Response.Write($"name:{name1}{c1}鐝"); -} -Response瀵硅薄 -Response.Write()鏂规硶锛氬悜褰撳墠HTTP鍝嶅簲娴佸啓鍏ユ枃鏈紝浣垮叾鎴愪负杩斿洖椤甸潰鐨勪竴閮ㄥ垎 - -Response.Redirect()鏂规硶:灏嗙敤鎴蜂粠璇锋眰椤甸潰閲嶆柊瀹氬悜鎴栬浆鍒板彟涓椤甸潰 - -
-
- Page1 - 濮撳悕:
- -
- -
-
-protected void Page_Load(object sender, EventArgs e) -{ - -} -protected void btn_Click(object sender, EventArgs e) -{ - string name = box1.Text; - string sex = ""; - //checked - if (rbtn1.Checked == true) - { - sex = "鍏堢敓"; - } - else - { - sex = "濂冲+"; - } - Response.Redirect($"Page2.aspx?name={name}&sex={sex}"); -} -
-
- Page2 - -
-
-protected void Page_Load(object sender, EventArgs e)= -{ - //Response閲嶅畾鍚戯細 - //鏀瑰彉缃戝潃锛 - //澶栭儴閲嶅畾鍚 - //Response.Redirect("https://www.baidu.com/"); - //鍐呴儴閲嶅畾鍚 - //Response.Redirect("Page3.aspx"); - string name = Request.Params["name"]; - string sex = Request.Params["sex"]; - Response.Write($"娆㈣繋{name}{sex}鐧诲綍."); -} -protected void btn1_Click(object sender, EventArgs e) -{ - //閲嶅畾鍚 Response瀵硅薄 - Response.Redirect("Page3.aspx"); -} -
-
- Page3 -
-
-protected void Page_Load(object sender, EventArgs e) -{ - -} -Server瀵硅薄 - Server.Execute()鏂规硶:鍦║RL鍙傛暟鎸囧畾鐨勯〉闈㈠鐞嗗畬鍚庯紝鎺у埗鏉冭繑鍥炵粰鍏堝墠鐨勯〉闈㈡垨璋冪敤姝ゆ柟娉曠殑椤甸潰锛屽苟涓斾粠姝ゆ柟娉曡皟鐢ㄥ悗鐨勮鍙ョ户缁墽琛屻 - Server.Transfer()鏂规硶:鍦║RL鍙傛暟鎸囧畾鐨勯〉闈㈠鐞嗗畬鍚庯紝鎺у埗鏉冧笉浼氳繑鍥炵粰鍏堝墠鐨勯〉闈紝涔熶笉浼氳繑鍥炵粰璋冪敤姝ゆ柟娉曠殑椤甸潰锛岀洿鍒板湪鏂伴〉闈㈠畬鎴愮粨鏉熴 -
-
- Page1 - - -
-
-protected void Page_Load(object sender, EventArgs e)= -{ - -} -protected void btn2_Click(object sender, EventArgs e) -{ - //Server瀵硅薄 - Server.Execute("Page2.aspx"); - Response.Write("Execute"); -} -protected void btn3_Click(object sender, EventArgs e) -{ - Server.Transfer("Page2.aspx"); - Response.Write("Transfer"); -} -
-
- Page2 -
-
-protected void Page_Load(object sender, EventArgs e) -{ - -} -``` - -- Gitee From a2477875b9d00daf7073c7ae9373c93b8b1d624f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 04:27:39 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E6=B1=9F=E5=98=89=E5=85=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Asp.net\347\254\224\350\256\260.md" | 552 ------------------ 1 file changed, 552 deletions(-) delete mode 100644 "\346\261\237\345\230\211\345\205\264/Asp.net\347\254\224\350\256\260.md" diff --git "a/\346\261\237\345\230\211\345\205\264/Asp.net\347\254\224\350\256\260.md" "b/\346\261\237\345\230\211\345\205\264/Asp.net\347\254\224\350\256\260.md" deleted file mode 100644 index c2c10ec..0000000 --- "a/\346\261\237\345\230\211\345\205\264/Asp.net\347\254\224\350\256\260.md" +++ /dev/null @@ -1,552 +0,0 @@ -# Asp.net绗旇 - -## 鍒濊瘑 - -### cs - -C/S鏄疌lient/Server鐨勭缉鍐欍傛湇鍔″櫒閫氬父閲囩敤楂樻ц兘鐨凱C銆佸伐浣滅珯鎴栧皬鍨嬫満锛 - -骞堕噰鐢ㄥぇ鍨嬫暟鎹簱锛堚淢ySQL鐭ヨ瘑搴撯)绯荤粺锛屽Oracle銆丼ybase銆両nFORMix鎴 - -SQL Server銆傚鎴风闇瑕佸畨瑁呬笓鐢ㄧ殑瀹㈡埛绔蒋浠躲 - -### bs - -B/锛虫槸Browser/Server鐨勭缉鍐欙紝瀹㈡埛鏈轰笂鍙瀹夎涓涓祻瑙堝櫒锛圔rowser锛夛紝 - -濡侼etscape Navigator鎴朓nternet Explorer锛屾湇鍔″櫒瀹夎Oracle銆丼ybase銆両nFORMix鎴 - - SQL Server绛夋暟鎹簱銆傚湪杩欑缁撴瀯涓嬶紝鐢ㄦ埛鐣岄潰瀹屽叏閫氳繃WWW娴忚鍣ㄥ疄鐜帮紝 - -涓閮ㄥ垎浜嬪姟閫昏緫鍦ㄥ墠绔疄鐜帮紝浣嗘槸涓昏浜嬪姟閫昏緫鍦ㄦ湇鍔″櫒绔疄鐜般 - -娴忚鍣ㄩ氳繃锛積b Server 鍚屾暟鎹簱杩涜鏁版嵁浜や簰銆 - -## 闈欐佺綉椤&鏈嶅姟鍣ㄧ寮鍙戞妧鏈 - -闈欐佺綉椤: - - 浠.html 鎴栬.htm 缁撳熬鐨勭綉椤 - - 鍙兘鍗曠函鐨勬樉绀烘枃鏈拰鍥惧儚 - - 鏃犳硶鍜岀敤鎴锋帴浜掞紝鏃犳硶鏍规嵁鐢ㄦ埛鐨勮姹傛樉绀轰笉鍚岀殑缃戦〉鍐呭 - -鏈嶅姟鍣ㄧ寮鍙戞妧鏈: - - 涓嶄粎鍙互鏄剧ず鏂囨湰鍜屽浘鍍 - - 杩樺彲浠ユ牴鎹敤鎴疯姹傦紝鍔ㄦ佹樉绀轰笉鍚岀殑缃戦〉鍐呭(涓庡悗鍙颁氦浜) - -渚嬪瓙 - -html椤甸潰 - - - - - - - - -
- 璐﹀彿锛 - 瀵嗙爜锛 - -
- - - -鍚庡彴澶勭悊 - -```c# -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace WebApplication2.NewFolder2 -{ - public class Class1 - { - public bool check(string uname,string mname) { - if (uname == "123" && mname == "123") { return true; } - else { return false; } - - } - } - -} -``` - - - -```c# -public class Handler1 : IHttpHandler - { - - public void ProcessRequest(HttpContext context) - { - context.Response.ContentType = "text/plain"; - string a = context.Request.Params["uname"]; - string b = context.Request.Params["mname"]; - NewFolder2.Class1 s = new NewFolder2.Class1(); - if (s.check(a, b)) { context.Response.Write("鐧诲叆鎴愬姛"); } - else { context.Response.Write("璐﹀彿鎴栧瘑鐮侀敊璇"); } - } - - public bool IsReusable - { - get - { - return false; - } - } - } - -} -``` - -## 椤甸潰瀵硅薄 - -### 缃戦〉鑴氭湰 - -閫氬父缃戦〉鑴氭湰鍙互瀹屾垚鍝簺浠诲姟锛 - -鎸囧畾杈撳叆鏂囨湰鎴栧崟鍑绘寜閽悗椤甸潰鐨勮涓 - -鏍规嵁鐢ㄦ埛鐨勮緭鍏ユ垨閫夋嫨灏嗗簲鐢ㄧ▼搴忎粠涓涓〉闈㈠鑸嚦鍏朵粬椤甸潰 - -鏀堕泦鎴栧瓨鍌ㄦ潵鑷鎴风鐨勪俊鎭 - -鎵ц鏁版嵁搴撴搷浣滐紝濡傛煡璇€佹樉绀烘暟鎹簱鏁版嵁绛 - -鎸夌収鑴氭湰鎵ц鐨勪綅缃紝缃戦〉鑴氭湰鍙垎涓烘湇鍔″櫒绔剼鏈拰瀹㈡埛绔剼鏈 - -### 缃戦〉鐢熸垚杩囩▼ - -1.瀹㈡埛绔偣鍑绘彁浜ゆ寜閽垨鑰呰Е鍙戞帶浠剁殑浜嬩欢 - -2.鏈嶅姟鍣ㄧ鍒锋柊鏁翠釜椤甸潰 - -3.鎵цpage_load浜嬩欢 - -4.鎵ц鍏蜂綋鎺т欢鐨勪簨浠跺苟缁欓〉闈㈡帶鍒惰祴鍊 - -5.閲嶆柊鐢熸垚鏂伴〉闈㈢殑HTML - -\6. 浣跨敤Response瀵硅薄杩斿洖鍖呭惈鏂版暟鎹殑html椤甸潰 - -7.娴忚鍣ㄧ湅鍒板埛鏂板悗鐨勯〉闈 - - - -### Page鎸囦护 - - - -| **灞** **鎬** | **璇** **鏄** | -| ------------------ | ------------------------------------------------------------ | -| AutoEventWireUp | 璁剧疆涓篢rue鏃讹紝鎸囧畾椤甸潰浜嬩欢鑷姩瑙﹀彂銆傝繖涓睘鎬х殑榛樿璁剧疆鏄疶rue | -| Buffer | 璁剧疆涓篢rue鏃讹紝鏀寔HTTP鍝嶅簲缂撳瓨銆傝繖涓睘鎬х殑榛樿璁剧疆鏄疶rue | -| ClassName | 鎸囧畾缂栬瘧椤甸潰鏃剁粦瀹氬埌椤甸潰涓婄殑绫诲悕 | -| CodeFile | 寮曠敤涓庨〉闈㈢浉鍏崇殑鍚庡彴缂栫爜鏂囦欢 | -| CodePage | 鎸囧畾鍝嶅簲鐨勪唬鐮侀〉闈㈠ | -| ContentType | 鎶婂搷搴旂殑HTTP鍐呭绫诲瀷瀹氫箟涓烘爣鍑哅IME绫诲瀷 | -| Debug | 璁剧疆涓篢rue鏃讹紝鐢ㄨ皟璇曠鍙风紪璇戦〉闈 | -| EnableSessionState | 璁剧疆涓篢rue鏃讹紝鏀寔椤甸潰鐨勪細璇濈姸鎬侊紝鍏堕粯璁よ缃槸False | -| EnableTheming | 璁剧疆涓篢rue鏃讹紝椤甸潰鍙互浣跨敤涓婚銆傚叾榛樿璁剧疆鏄疐alse | -| EnableViewState | 纭畾鏄惁涓烘湇鍔″櫒鎺т欢淇濇寔椤甸潰鐨刅iewState銆傞粯璁ゅ兼槸True | - -| **ErrorPage** | **涓烘墍鏈夋湭澶勭悊鐨勯〉闈㈠紓甯告寚瀹氱敤浜庡彂閫佷俊鎭殑****URL** | -| ---------------- | ------------------------------------------------------------ | -| Language | 瀹氫箟鍐呯疆鏄剧ず鍜岃剼鏈潡鎵浣跨敤鐨勮瑷 | -| MasterPageFile | 甯︿竴涓猄tring鍊硷紝鎸囧悜椤甸潰鎵浣跨敤鐨刴aster椤甸潰鐨勫湴鍧銆傝繖涓睘鎬у湪鍐呭椤甸潰涓娇鐢 | -| ResponseEncoding | 鎸囧畾椤甸潰鍐呭鐨勫搷搴旂紪鐮 | -| Theme | 浣跨敤涓婚鍔熻兘锛屾妸鎸囧畾鐨勪富棰樺簲鐢ㄤ簬椤甸潰 | -| Title | 搴旂敤椤甸潰鐨勬爣棰樸傝繖涓睘鎬т富瑕佺敤浜庡繀椤诲簲鐢ㄩ〉闈㈡爣棰樼殑鍐呭椤甸潰锛岃屼笉鏄簲鐢╩aster椤甸潰涓寚瀹氬唴瀹圭殑椤甸潰 | -| Trace | 璁剧疆涓篢rue鏃讹紝婵娲婚〉闈㈣窡韪紝鍏堕粯璁ゅ兼槸False | -| TraceMode | 鎸囧畾婵娲昏窡韪姛鑳芥椂濡備綍鏄剧ず璺熻釜娑堟伅銆傝繖涓睘鎬х殑璁剧疆鍙互鏄疭ortByTime鎴朣ortByCategory锛岄粯璁よ缃槸SortByTime | -| Transaction | 鎸囧畾椤甸潰涓婃槸鍚︽敮鎸佷簨鍔″鐞嗐傝繖涓睘鎬х殑璁剧疆鍙互鏄疦otSupported銆丼upported銆丷equired鍜孯equiresNew锛岄粯璁ゅ兼槸NotSupported | - -### Page.IsPostBack灞炴 - -鍦≒age_Load浜嬩欢涓紪鍐欏涓嬩唬鐮侊細 - - - -```c# -protected void Page_Load(object sender, EventArgs e) - { - if(Page.PreviousPage != null) - { - TextBox tname= (TextBox)PreviousPage.FindControl("TextBox1"); - TextBox tpwd = (TextBox)PreviousPage.FindControl("TextBox2"); - - if(tname.Text == "123" && tpwd.Text == "admin") - { - lbl2.Text = "鐧婚檰鎴愬姛"; - } - else - { - lbl2.Text = "鐧婚檰澶辫触"; - } - - -``` - - - -鍦ㄦ彁浜ゆ寜閽殑鈥溾濅簨浠朵腑缂栧啓濡備笅浠g爜锛 - - - -### 璺ㄩ〉闈紶鍊 - -姝ラ锛 - -1.鍦≒age1涓娇鐢↖sPostBackUrl鎸囧畾Page2 - -2.鍦≒age2涓殑Page_Load缂栧啓浠g爜锛 - - 1锛 棣栧厛鍒ゆ柇Page2椤甸潰鏄惁鏈変笂涓椤碉紝濡傛灉鏄病鏈夐偅涔圥age.Previous == null - - 2锛夊叾娆′娇鐢≒revious.FindControl()鏌ユ壘涓婁竴椤电殑鎸囧畾ID鍊 - -渚嬪瓙 - -```c# -//瀛樻斁淇℃伅 - -ViewState["nameId"]="0001"; - - - -//璇诲彇淇℃伅 - -String NameID = ViewState["nameID"].ToString(); -``` - -## 鍐呯疆瀵硅薄 - -### Request瀵硅薄 - -鈥**Request****濡備綍鑾峰彇浼犻掕繃鏉ョ殑鏁版嵁** - -鈥ueryString(鏌ヨ瀛楃涓)锛氳幏鍙栭氳繃URL浼犻掕繃鏉ョ殑鏁版嵁 - -鈥orm(琛ㄥ崟鏁版嵁)锛氳幏鍙栭氳繃琛ㄥ崟鎻愪氦浼犺緭鐨勬暟鎹 - -鈥erverVariables灞炴э細鑾峰彇Web鏈嶅姟鍣ㄥ彉閲忕殑闆嗗悎 - -鈥arams锛氫互涓婁笁绉嶆柟寮忎紶杈撶殑鍐呭閮藉彲浠ヤ娇鐢ㄨ灞炴ц幏鍙 - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequestPage.aspx.cs" Inherits="ViewStatePage.Request瀵硅薄.RequestPage" %> - - - - - - - - - - - - - -
-
- content -
-
- - - -``` - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequestPage2.aspx.cs" Inherits="ViewStatePage.Request瀵硅薄.RequestPage2" %> - - - - - - - - - - - - - -
-
- 椤甸潰2 -
-
- - - -``` - - - -### Response瀵硅薄 - -Response.Write() - - - -Response.Redirect() - -渚嬪瓙 - -page1 - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="ViewStatePage.Response瀵硅薄.Page1" %> - - - - - - - - - - - - -
-
- 濮撳悕:
- -
- - - -
-
- - - -``` - -```c# -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace ViewStatePage.Response瀵硅薄 -{ - public partial class Page1 : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - - } - - protected void btn_Click(object sender, EventArgs e) - { - string name = box1.Text; - string sex = ""; - //checked - if (rbtn1.Checked == true) - { - sex = "鍏堢敓"; - } - else - { - sex = "濂冲+"; - } - - Response.Redirect($"Page2.aspx?name={name}&sex={sex}"); - } - } - -} -``` - -page2 - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page2.aspx.cs" Inherits="ViewStatePage.Response瀵硅薄.Page2" %> - - - - - - - - - - - - - -
-
- - - -
-
- - - -``` - -```c# -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace ViewStatePage.Response瀵硅薄 -{ - public partial class Page2 : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - //Response閲嶅畾鍚戯細 - //鏀瑰彉缃戝潃锛 - //澶栭儴閲嶅畾鍚 - //Response.Redirect("https://www.baidu.com/"); - - //鍐呴儴閲嶅畾鍚 - //Response.Redirect("Page3.aspx"); - - string name = Request.Params["name"]; - string sex = Request.Params["sex"]; - - Response.Write($"娆㈣繋{name}{sex}鐧诲綍."); - } - - protected void btn1_Click(object sender, EventArgs e) - { - //閲嶅畾鍚 Response瀵硅薄 - Response.Redirect("Page3.aspx"); - - } - - protected void btn2_Click(object sender, EventArgs e) - { - //Server瀵硅薄 - Server.Execute("Page3.aspx"); - Response.Write("Execute"); - } - - protected void btn3_Click(object sender, EventArgs e) - { - Server.Transfer("Page3.aspx"); - Response.Write("Transfer"); - } - } - -} -``` - -page3 - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page3.aspx.cs" Inherits="ViewStatePage.Response瀵硅薄.Page3" %> - - - - - - - - - - - - - -
-
- 3 -
-
- - - -``` - -### ViewState - -```html -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page.aspx.cs" Inherits="ViewStatePage._1ViewState瀵硅薄.Page" %> - - - - - - - - - - - - -
-
- 浠婂ぉ鏈 - 0 - 瀵瑰厔濡圭浉璁 - - -
-
- - - -``` - -```c# -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace ViewStatePage._1ViewState瀵硅薄 -{ - public partial class Page : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - //浠ラ敭鍊煎瀛樺湪 - //1.鍒濆鍖 - if (!IsPostBack) - { - ViewState["count"] = 0; - } - } - - //娌℃湁鎴愬憳鍙橀噺 - //HTTP鍗忚锛氭棤鐘舵侊紙锛 - //int count = 0; - protected void Button1_Click(object sender, EventArgs e) - { - int n = (int)ViewState["count"]; - n++; - - //杈撳嚭鍒伴〉闈笂 - lit.Text = n.ToString(); - - ViewState["count"] = n; - } - } - -} -``` - -- Gitee From 2374d106ad852ac327c13ca39019fd0e0e94dd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 04:27:44 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=94=B0=E9=91=AB=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ASP.NETt\347\254\224\350\256\260.md" | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 "\347\224\260\351\221\253\345\274\272/ASP.NETt\347\254\224\350\256\260.md" diff --git "a/\347\224\260\351\221\253\345\274\272/ASP.NETt\347\254\224\350\256\260.md" "b/\347\224\260\351\221\253\345\274\272/ASP.NETt\347\254\224\350\256\260.md" deleted file mode 100644 index 80f552e..0000000 --- "a/\347\224\260\351\221\253\345\274\272/ASP.NETt\347\254\224\350\256\260.md" +++ /dev/null @@ -1,12 +0,0 @@ -鍒涘缓绗竴涓狝SP.net Web搴旂敤绋嬪簭 - -```html -TextBox鎺т欢锛氭帶浠剁敤浜庡垱寤虹敤鎴峰彲杈撳叆鏂囨湰鐨勬枃鏈銆 - -Button鎺т欢锛氱敤浜庢樉绀烘寜閽傛寜閽彲浠ユ槸鎻愪氦鎸夐挳鎴栧懡浠ゆ寜閽紝鑰岃鎺т欢灞炰簬鎻愪氦鎸夐挳銆 - - Text閲岀殑鍐呭灏辨槸鎸夐敭鏄剧ず鐨勫唴瀹 -Label鎺т欢锛 鐢ㄤ簬鏄剧ず鐢ㄦ埛涓嶈兘缂栬緫鐨勬枃鏈垨鍥惧儚 - -``` - -- Gitee From 2b18a89a6950f5687a0c793d521bdb3bb4763cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 04:27:50 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=AC=94=E8=AE=B0.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\254\224\350\256\260.txt" | 101 --------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 "\347\254\224\350\256\260.txt" diff --git "a/\347\254\224\350\256\260.txt" "b/\347\254\224\350\256\260.txt" deleted file mode 100644 index 731f0d5..0000000 --- "a/\347\254\224\350\256\260.txt" +++ /dev/null @@ -1,101 +0,0 @@ -涓銆丄SP.NET -ASP.NET鍔熻兘 -澶氳瑷鏀寔 -浠g爜缂栬瘧鎵ц -缂撳瓨鏈哄埗 -鏈嶅姟鍣ㄦ帶浠 -Web鏈嶅姟 -鐘舵佺鐞 -瀹夊叏绠$悊 -閰嶇疆鍜岄儴缃 - -浠涔堟槸IIS -1銆佸悓鏍锋槸鍔ㄦ佺綉椤垫妧鏈紝ASP.NET灏卞儚JSP闇瑕乀omcat鏈嶅姟鍣ㄦ垨鑰匒pache鏈嶅姟鍣ㄤ竴鏍凤紝ASP.NET涔熼渶瑕佷娇鐢╓eb鏈嶅姟鍣ㄤ綔涓哄叾鍙戝竷骞冲彴锛屼竴鑸娇鐢↖IS浣滀负鍏禬eb鏈嶅姟鍣ㄣ侷IS鏄疘nternet淇℃伅鏈嶅姟锛圛nternet Information Server锛夌殑缂╁啓锛屾槸寰蒋鐨処nternet鏈嶅姟鍣 - -2銆両IS鏄疻indows Servers 鎿嶄綔绯荤粺鍏嶈垂鎹嗙粦鐨勭粍浠 - -3銆両IS鏄痺eb搴旂敤绋嬪簭杩愯鐨勬湇鍔″櫒 - - 浜屻侀〉闈㈠璞 -Page鎸囦护 -| **灞** **鎬** | **璇** **鏄** | -| ------------------ | ------------------------------------------------------------ | -| AutoEventWireUp | 璁剧疆涓篢rue鏃讹紝鎸囧畾椤甸潰浜嬩欢鑷姩瑙﹀彂銆傝繖涓睘鎬х殑榛樿璁剧疆鏄疶rue | -| Buffer | 璁剧疆涓篢rue鏃讹紝鏀寔HTTP鍝嶅簲缂撳瓨銆傝繖涓睘鎬х殑榛樿璁剧疆鏄疶rue | -| ClassName | 鎸囧畾缂栬瘧椤甸潰鏃剁粦瀹氬埌椤甸潰涓婄殑绫诲悕 | -| CodeFile | 寮曠敤涓庨〉闈㈢浉鍏崇殑鍚庡彴缂栫爜鏂囦欢 | -| CodePage | 鎸囧畾鍝嶅簲鐨勪唬鐮侀〉闈㈠ | -| ContentType | 鎶婂搷搴旂殑HTTP鍐呭绫诲瀷瀹氫箟涓烘爣鍑哅IME绫诲瀷 | -| Debug | 璁剧疆涓篢rue鏃讹紝鐢ㄨ皟璇曠鍙风紪璇戦〉闈 | -| EnableSessionState | 璁剧疆涓篢rue鏃讹紝鏀寔椤甸潰鐨勪細璇濈姸鎬侊紝鍏堕粯璁よ缃槸False | -| EnableTheming | 璁剧疆涓篢rue鏃讹紝椤甸潰鍙互浣跨敤涓婚銆傚叾榛樿璁剧疆鏄疐alse | -| EnableViewState | 纭畾鏄惁涓烘湇鍔″櫒鎺т欢淇濇寔椤甸潰鐨刅iewState銆傞粯璁ゅ兼槸True | -| **ErrorPage** | **涓烘墍鏈夋湭澶勭悊鐨勯〉闈㈠紓甯告寚瀹氱敤浜庡彂閫佷俊鎭殑****URL** | -| ---------------- | ------------------------------------------------------------ | -| Language | 瀹氫箟鍐呯疆鏄剧ず鍜岃剼鏈潡鎵浣跨敤鐨勮瑷 | -| MasterPageFile | 甯︿竴涓猄tring鍊硷紝鎸囧悜椤甸潰鎵浣跨敤鐨刴aster椤甸潰鐨勫湴鍧銆傝繖涓睘鎬у湪鍐呭椤甸潰涓娇鐢 | -| ResponseEncoding | 鎸囧畾椤甸潰鍐呭鐨勫搷搴旂紪鐮 | -| Theme | 浣跨敤涓婚鍔熻兘锛屾妸鎸囧畾鐨勪富棰樺簲鐢ㄤ簬椤甸潰 | -| Title | 搴旂敤椤甸潰鐨勬爣棰樸傝繖涓睘鎬т富瑕佺敤浜庡繀椤诲簲鐢ㄩ〉闈㈡爣棰樼殑鍐呭椤甸潰锛岃屼笉鏄簲鐢╩aster椤甸潰涓寚瀹氬唴瀹圭殑椤甸潰 | -| Trace | 璁剧疆涓篢rue鏃讹紝婵娲婚〉闈㈣窡韪紝鍏堕粯璁ゅ兼槸False | -| TraceMode | 鎸囧畾婵娲昏窡韪姛鑳芥椂濡備綍鏄剧ず璺熻釜娑堟伅銆傝繖涓睘鎬х殑璁剧疆鍙互鏄疭ortByTime鎴朣ortByCategory锛岄粯璁よ缃槸SortByTime | -| Transaction | 鎸囧畾椤甸潰涓婃槸鍚︽敮鎸佷簨鍔″鐞嗐傝繖涓睘鎬х殑璁剧疆鍙互鏄疦otSupported銆丼upported銆丷equired鍜孯equiresNew锛岄粯璁ゅ兼槸NotSupported | - -##### Page瀵硅薄浜嬩欢 - -``` -AbortTransaction -CommitTransaction -DataBinding -Disposed -Error -Init -Load -PreRender -Unload - -``` - -##### Page瀵硅薄浜嬩欢-2 - -``` -涓婚〉闈簨浠剁殑鍚姩椤哄簭 -PreInit -Init -InitComplete -PreLoad -Load -LoadComplete -PreRender -PreRenderComplete -Unload - -``` - -##### Page瀵硅薄灞炴 - -| **灞** **鎬** | **璇** **鏄** | -| --------------- | ------------------------------------------------------------ | -| Application | 涓哄綋鍓峎eb璇锋眰鑾峰彇Application,瀵逛簬姣忎釜Web搴旂敤绋嬪簭鏉ヨ,鍙』涓涓瀵硅薄鐨勫疄渚嬨傚畠鏄湁鎵鏈夎闂Web搴旂敤绋嬪簭鐨勫鎴风鍏变韩鐨 | -| EnableViewState | 鎸囧畾褰撳墠椤甸潰涓婄殑鏈嶅姟鍣ㄦ帶浠舵槸鍚﹀湪椤甸潰璇锋眰涔嬮棿淇濇寔ViewState銆傝鍊煎奖鍝嶇綉椤典笂鐨勬墍鏈夋帶浠讹紝鍚屾椂鍙栦唬鎺т欢鑷韩鐨勪换浣曚釜浜鸿缃 | -| ErrorPage | 鑾峰彇鎴栬缃敊璇〉闈紝鍦ㄥ彂鐢熸湭澶勭悊鐨勯〉寮傚父鐨勪簨浠舵椂璇锋眰娴忚鍣ㄥ皢琚噸瀹氬悜鍒拌椤 | -| ID | 鐢ㄤ簬鑾峰彇鎴栬缃甈age绫荤殑鐗瑰畾瀹炰緥鐨勬爣璇嗙 | -| IsPostBack | 鑾峰彇涓涓硷紝璇ュ兼寚绀洪〉闈㈡槸鍚︿负鍝嶅簲瀹㈡埛绔洖鍙戣屽姞杞斤紝鎴栬呭畠鏄惁姝h棣栨鍔犺浇鍜岃闂 | -| IsVaild | 鑾峰彇涓涓硷紝璇ュ兼寚绀洪〉闈㈤獙璇佹槸鍚︽垚鍔 | -| Request | 鐢ㄤ簬鑾峰彇HttpRequest瀵硅薄锛屾瀵硅薄涓庝粠瀹㈡埛鍙戦丠TTP璇锋眰鏁版嵁鐨勫綋鍓嶉〉闈㈠叧鑱 | -| Reponse | 鐢ㄤ簬鑾峰彇HttpResponse瀵硅薄锛屾瀵硅薄涓庡鎴峰彂閫丠TTP璇锋眰鏁版嵁鐨勫綋鍓嶉〉闈㈠叧鑱 | -| Server | 瀵瑰綋鍓峉erver瀵硅薄鐨勫紩鐢 | -| Session | 鐢ㄤ簬鑾峰彇ASP.NET鎻愪緵鐨勫綋鍓峉ession瀵硅薄 | - - - - - - 璺ㄩ〉闈紶鍊 - -``` -姝ラ锛 -1.鍦≒age1涓娇鐢↖sPostBackUrl鎸囧畾Page2 -2.鍦≒age2涓殑Page_Load缂栧啓浠g爜锛 - 1锛 棣栧厛鍒ゆ柇Page2椤甸潰鏄惁鏈変笂涓椤碉紝濡傛灉鏄病鏈夐偅涔圥age.Previous == null - 2锛夊叾娆′娇鐢≒revious.FindControl()鏌ユ壘涓婁竴椤电殑鎸囧畾ID鍊 \ No newline at end of file -- Gitee From 0775b96bef98711d8a3c501cd09872343a8cf09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E9=87=91=E6=98=9F?= <3441777097@qq.com> Date: Mon, 23 May 2022 12:29:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Webform\345\210\235\350\257\206.md" | 58 +++++ ...05\347\275\256\345\257\271\350\261\241.md" | 206 ++++++++++++++++++ ...51\235\242\345\257\271\350\261\241Page.md" | 121 ++++++++++ 3 files changed, 385 insertions(+) create mode 100644 "10\344\275\231\351\207\221\346\230\237/Webform\345\210\235\350\257\206.md" create mode 100644 "10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" create mode 100644 "10\344\275\231\351\207\221\346\230\237/\351\241\265\351\235\242\345\257\271\350\261\241Page.md" diff --git "a/10\344\275\231\351\207\221\346\230\237/Webform\345\210\235\350\257\206.md" "b/10\344\275\231\351\207\221\346\230\237/Webform\345\210\235\350\257\206.md" new file mode 100644 index 0000000..fa94bba --- /dev/null +++ "b/10\344\275\231\351\207\221\346\230\237/Webform\345\210\235\350\257\206.md" @@ -0,0 +1,58 @@ +## Webform鍒濆 + +action = "涓鑸鐞嗙▼搴" +method = post(闅愬紡鍙戦) +method = get(鏄惧紡鍙戦) + +鍒涘缓绗竴涓猈eb搴旂敤绐椾綋 + +```asp +
+ 璐﹀彿: + 瀵嗙爜: + +
+``` + +```c# +//涓鑸鐞嗙▼搴 +public void ProcessRequest(HttpContext context) +{ + context.Response.ContentType = "text/plain"; + //1.浠庡墠鍙版帴鏀舵暟鎹埌鍚庡彴 + string uname = context.Request.Params["uname"]; + string upwd = context.Request.Params["upwd"]; + DATA.LoginCheck lc = new DATA.LoginCheck(); + if (lc.CheckAccount(uname, upwd)) + { + context.Response.Write("鐧婚檰鎴愬姛"); + } + else + { + context.Response.Write("鐢ㄦ埛鍚嶆垨鑰呭瘑鐮侀敊璇"); + } +} +public bool IsReusable //鏄惁鑷姩缂撳瓨 +{ + get + { + return false; + } +} +``` + +```c# +//妯℃嫙鏁版嵁搴 +public bool CheckAccount(string uname, string upwd) +{ + if (uname == "123" && upwd == "admin") + { + return true; + } + else + { + return false; + } +} +``` + diff --git "a/10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" "b/10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" new file mode 100644 index 0000000..ba86914 --- /dev/null +++ "b/10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" @@ -0,0 +1,206 @@ +#### ViewState瀵硅薄 + +```asp +
+
+
+ +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + //鍒濆鍖 + if(!IsPostBack) + { + ViewState["lbl1"] = 0; + } +} +//娌℃湁鎴愬憳鍙橀噺 +//HTTP鍗忚:鏃犵姸鎬 +protected void Button1_Click(object sender, EventArgs e) +{ + int c = (int)ViewState["lbl1"]; + c++; + lbl1.Text = c.ToString(); + ViewState["lbl1"] = c; +} +``` + +#### Request瀵硅薄 + +- [x] QueryString(鏌ヨ瀛楃涓)锛氳幏鍙栭氳繃URL浼犻掕繃鏉ョ殑鏁版嵁 +- [ ] Form(琛ㄥ崟鏁版嵁)锛氳幏鍙栭氳繃琛ㄥ崟鎻愪氦浼犺緭鐨勬暟鎹 +- [ ] ServerVariables灞炴э細鑾峰彇Web鏈嶅姟鍣ㄥ彉閲忕殑闆嗗悎 +- [x] Params锛氫互涓婁笁绉嶆柟寮忎紶杈撶殑鍐呭閮藉彲浠ヤ娇鐢ㄨ灞炴ц幏鍙 + +```asp +
+
+ Page1 + 璺宠浆 +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + +} +``` + +```asp +
+
+ Page2 +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + string name = Request.QueryString["name"]; + string c = Request.QueryString["class"]; + Response.Write($"name:{name}{c}鐝"); + string name1 = Request.Params["name"]; + string c1 = Request.Params["class"]; + Response.Write($"name:{name1}{c1}鐝"); +} +``` + +#### Response瀵硅薄 + +Response.Write()鏂规硶锛氬悜褰撳墠HTTP鍝嶅簲娴佸啓鍏ユ枃鏈紝浣垮叾鎴愪负杩斿洖椤甸潰鐨勪竴閮ㄥ垎 + +Response.Redirect()鏂规硶:灏嗙敤鎴蜂粠璇锋眰椤甸潰閲嶆柊瀹氬悜鎴栬浆鍒板彟涓椤甸潰 + +```asp +
+
+ Page1 + 濮撳悕:
+ +
+ +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + +} +protected void btn_Click(object sender, EventArgs e) +{ + string name = box1.Text; + string sex = ""; + //checked + if (rbtn1.Checked == true) + { + sex = "鍏堢敓"; + } + else + { + sex = "濂冲+"; + } + Response.Redirect($"Page2.aspx?name={name}&sex={sex}"); +} +``` + +```asp +
+
+ Page2 + +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e)= +{ + //Response閲嶅畾鍚戯細 + //鏀瑰彉缃戝潃锛 + //澶栭儴閲嶅畾鍚 + //Response.Redirect("https://www.baidu.com/"); + //鍐呴儴閲嶅畾鍚 + //Response.Redirect("Page3.aspx"); + string name = Request.Params["name"]; + string sex = Request.Params["sex"]; + Response.Write($"娆㈣繋{name}{sex}鐧诲綍."); +} +protected void btn1_Click(object sender, EventArgs e) +{ + //閲嶅畾鍚 Response瀵硅薄 + Response.Redirect("Page3.aspx"); +} +``` + +```asp +
+
+ Page3 +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + +} +``` + +#### Server瀵硅薄 + +- [x] Server.Execute()鏂规硶:鍦║RL鍙傛暟鎸囧畾鐨勯〉闈㈠鐞嗗畬鍚庯紝鎺у埗鏉冭繑鍥炵粰鍏堝墠鐨勯〉闈㈡垨璋冪敤姝ゆ柟娉曠殑椤甸潰锛屽苟涓斾粠姝ゆ柟娉曡皟鐢ㄥ悗鐨勮鍙ョ户缁墽琛屻 +- [x] Server.Transfer()鏂规硶:鍦║RL鍙傛暟鎸囧畾鐨勯〉闈㈠鐞嗗畬鍚庯紝鎺у埗鏉冧笉浼氳繑鍥炵粰鍏堝墠鐨勯〉闈紝涔熶笉浼氳繑鍥炵粰璋冪敤姝ゆ柟娉曠殑椤甸潰锛岀洿鍒板湪鏂伴〉闈㈠畬鎴愮粨鏉熴 + +```asp +
+
+ Page1 + + +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e)= +{ + +} +protected void btn2_Click(object sender, EventArgs e) +{ + //Server瀵硅薄 + Server.Execute("Page2.aspx"); + Response.Write("Execute"); +} +protected void btn3_Click(object sender, EventArgs e) +{ + Server.Transfer("Page2.aspx"); + Response.Write("Transfer"); +} +``` + +```asp +
+
+ Page2 +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + +} +``` + diff --git "a/10\344\275\231\351\207\221\346\230\237/\351\241\265\351\235\242\345\257\271\350\261\241Page.md" "b/10\344\275\231\351\207\221\346\230\237/\351\241\265\351\235\242\345\257\271\350\261\241Page.md" new file mode 100644 index 0000000..34e8005 --- /dev/null +++ "b/10\344\275\231\351\207\221\346\230\237/\351\241\265\351\235\242\345\257\271\350\261\241Page.md" @@ -0,0 +1,121 @@ +## 椤甸潰瀵硅薄Page + +#### 缃戦〉鐢熸垚杩囩▼鍒嗘瀽 + +```tex +绗竴娆¤姹: + 1.ASp.NET寮曟搸 + 2.鍚庡彴.cs缂栫爜绫 + 3.鐢熸垚鐨勯〉闈㈢被-缂栬瘧 + 4.鏁版嵁搴-澶勭悊 + 5.绋嬪簭闆嗗鐞嗗苟鍚堟垚鏁版嵁(鍝嶅簲) +绗簩娆¤姹: + 5.绋嬪簭闆嗗鐞嗗苟鍚堟垚鏁版嵁(鍝嶅簲) +``` + +#### 缃戦〉鐢熸垚杩囩▼鎬荤粨 + +```tex +1.瀹㈡埛绔偣鍑绘彁浜ゆ寜閽垨鑰呰Е鍙戞帶浠剁殑浜嬩欢 +2.鏈嶅姟鍣ㄧ鍒锋柊鏁翠釜椤甸潰 +3.鎵цpage_load浜嬩欢 +4.鎵ц鍏蜂綋鎺т欢鐨勪簨浠跺苟缁欓〉闈㈡帶鍒惰祴鍊 +5.閲嶆柊鐢熸垚鏂伴〉闈㈢殑HTML +6.浣跨敤Response瀵硅薄杩斿洖鍖呭惈鏂版暟鎹殑html椤甸潰 +7.娴忚鍣ㄧ湅鍒板埛鏂板悗鐨勯〉闈 +``` + +#### Page.IsPostBack灞炴 + +```asp +
+
+
+ +
+
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + //濡傛灉鏄涓娆″姞杞斤細 + //TextBox1.Text = "璇疯緭鍏ヨ处鍙"; + //濡傛灉鏄洖鍙戯紝 + + //绗竴娆″姞杞 + if (!IsPostBack) + { + TextBox1.Text = "璇疯緭鍏ヨ处鍙"; + } + else //鍥炲彂 + { + + } +} +protected void Button1_Click(object sender, EventArgs e) +{ + TextBox2.Text = TextBox1.Text; +} +``` + +#### 椤甸潰浼犲 + +```tex +//瀛樻斁淇℃伅 +ViewState["ID鍚嶇О"]="1"; +//璇诲彇淇℃伅 +String ID鍚嶇О = ViewState["ID鍚嶇О"].ToString(); +``` + +#### 璺ㄩ〉闈紶鍊 + +```asp +椤甸潰Page1 +
+
+ 璐﹀彿锛
+ 瀵嗙爜锛
+ +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + +} +``` + +```asp +椤甸潰Page2 +
+
+ +
+
+``` + +```c# +protected void Page_Load(object sender, EventArgs e) +{ + //鍒ゆ柇鏄惁璧峰椤碉紝濡傛灉鏄捣濮嬮〉锛孭age.PreviousPage灏嗕负绌 + if (Page.PreviousPage != null) + { + //PreviousPage.FindControl(string id)锛氬湪褰撳墠鐨勫懡鍚嶅鍣ㄤ腑锛堣繖閲屾寚瀹氱殑鏄疨reviousPage锛夋悳绱 鎸囧畾 id + TextBox t1 = (TextBox)PreviousPage.FindControl("TextBox1"); + TextBox t2 = (TextBox)PreviousPage.FindControl("TextBox2"); + if(t1.Text == "123" && t2.Text == "admin") + { + lbl2.Text = "鐧婚檰鎴愬姛"; + } + else + { + lbl2.Text = "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒"; + } + } +} +``` + -- Gitee