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 0000000000000000000000000000000000000000..fa94bba85bed2e9b2e9917c8d4f0560f2cc02c4c --- /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(显式发送) + +创建第一个Web应用窗体 + +```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/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/10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" similarity index 69% rename from "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" rename to "10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" index bb53ad97a1e5120fce2ed136efe23dac273dda4e..ba86914e6333df8826067c2f9e2d74eeb7c22118 100644 --- "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/10\344\275\231\351\207\221\346\230\237/\345\206\205\347\275\256\345\257\271\350\261\241.md" @@ -1,175 +1,206 @@ -``` -Transfer 方法把一个 ASP 文件中创建的所有状态信息(所有 application/session 变量以及所有 request 集合中的项目)发送(传输)到另一个 ASP 文件中。 - -当第二个 ASP 完成任何时,它不会返回到第一个 ASP 页面。 - -注意:Transfer 方法是 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()方法:在URL参数指定的页面处理完后,控制权返回给先前的页面或调用此方法的页面,并且从此方法调用后的语句继续执行。 - Server.Transfer()方法:在URL参数指定的页面处理完后,控制权不会返回给先前的页面,也不会返回给调用此方法的页面,直到在新页面完成结束。 -
-
- 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) -{ - -} -``` - +#### 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()方法:在URL参数指定的页面处理完后,控制权返回给先前的页面或调用此方法的页面,并且从此方法调用后的语句继续执行。 +- [x] Server.Transfer()方法:在URL参数指定的页面处理完后,控制权不会返回给先前的页面,也不会返回给调用此方法的页面,直到在新页面完成结束。 + +```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 0000000000000000000000000000000000000000..34e800569d8421334be84d1e30ec37dcf45ee153 --- /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) +{ + //判断是否起始页,如果是起始页,Page.PreviousPage将为空 + if (Page.PreviousPage != null) + { + //PreviousPage.FindControl(string id):在当前的命名容器中(这里指定的是PreviousPage)搜索 指定 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 = "用户名或密码错误"; + } + } +} +``` + 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 4d7d034c1d173709650f554ce269cab64e26f851..0000000000000000000000000000000000000000 --- "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/SClient/ServerдͨøܵPCվСͻ -ôݿ⣨MySQL֪ʶ⡱)ϵͳOracleSybaseInFORMix -SQL ServerͻҪװרõĿͻ - -B/Browser/ServerдͻֻҪװһBrowser -Netscape NavigatorInternet ExplorerװOracleSybaseInFORMix - SQL Serverݿ⡣ֽṹ£ûȫͨWWWʵ֣ -һ߼ǰʵ֣Ҫ߼ڷʵ֡ -ͨeb 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 ߼() } --->.aspxaspx.csͬ - Webformվҳ Webform - - - - - - - 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 c2c10eca24e4b2d86f6378773d1fe04dc1712dce..0000000000000000000000000000000000000000 --- "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是Client/Server的缩写。服务器通常采用高性能的PC、工作站或小型机, - -并采用大型数据库(“MySQL知识库”)系统,如Oracle、Sybase、InFORMix或 - -SQL Server。客户端需要安装专用的客户端软件。 - -### bs - -B/S是Browser/Server的缩写,客户机上只要安装一个浏览器(Browser), - -如Netscape Navigator或Internet Explorer,服务器安装Oracle、Sybase、InFORMix或 - - SQL Server等数据库。在这种结构下,用户界面完全通过WWW浏览器实现, - -一部分事务逻辑在前端实现,但是主要事务逻辑在服务器端实现。 - -浏览器通过Web 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 | 设置为True时,指定页面事件自动触发。这个属性的默认设置是True | -| Buffer | 设置为True时,支持HTTP响应缓存。这个属性的默认设置是True | -| ClassName | 指定编译页面时绑定到页面上的类名 | -| CodeFile | 引用与页面相关的后台编码文件 | -| CodePage | 指定响应的代码页面值 | -| ContentType | 把响应的HTTP内容类型定义为标准MIME类型 | -| Debug | 设置为True时,用调试符号编译页面 | -| EnableSessionState | 设置为True时,支持页面的会话状态,其默认设置是False | -| EnableTheming | 设置为True时,页面可以使用主题。其默认设置是False | -| EnableViewState | 确定是否为服务器控件保持页面的ViewState。默认值是True | - -| **ErrorPage** | **为所有未处理的页面异常指定用于发送信息的****URL** | -| ---------------- | ------------------------------------------------------------ | -| Language | 定义内置显示和脚本块所使用的语言 | -| MasterPageFile | 带一个String值,指向页面所使用的master页面的地址。这个属性在内容页面中使用 | -| ResponseEncoding | 指定页面内容的响应编码 | -| Theme | 使用主题功能,把指定的主题应用于页面 | -| Title | 应用页面的标题。这个属性主要用于必须应用页面标题的内容页面,而不是应用master页面中指定内容的页面 | -| Trace | 设置为True时,激活页面跟踪,其默认值是False | -| TraceMode | 指定激活跟踪功能时如何显示跟踪消息。这个属性的设置可以是SortByTime或SortByCategory,默认设置是SortByTime | -| Transaction | 指定页面上是否支持事务处理。这个属性的设置可以是NotSupported、Supported、Required和RequiresNew,默认值是NotSupported | - -### Page.IsPostBack属性 - -在Page_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 = "登陆失败"; - } - - -``` - - - -在提交按钮的“”事件中编写如下代码: - - - -### 跨页面传值 - -步骤: - -1.在Page1中使用IsPostBackUrl指定Page2 - -2.在Page2中的Page_Load编写代码: - - 1) 首先判断Page2页面是否有上一页,如果是没有那么Page.Previous == null - - 2)其次使用Previous.FindControl()查找上一页的指定ID值 - -例子 - -```c# -//存放信息 - -ViewState["nameId"]="0001"; - - - -//读取信息 - -String NameID = ViewState["nameID"].ToString(); -``` - -## 内置对象 - -### Request对象 - -•**Request****如何获取传递过来的数据** - -•QueryString(查询字符串):获取通过URL传递过来的数据 - -•Form(表单数据):获取通过表单提交传输的数据 - -•ServerVariables属性:获取Web服务器变量的集合 - -•Params:以上三种方式传输的内容都可以使用该属性获取 - -```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; - } - } - -} -``` - 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 80f552ef910687897129c949000dc55da3e514ec..0000000000000000000000000000000000000000 --- "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 @@ -创建第一个ASP.net Web应用程序 - -```html -TextBox控件:控件用于创建用户可输入文本的文本框。 - -Button控件:用于显示按钮。按钮可以是提交按钮或命令按钮,而该控件属于提交按钮。 - - Text里的内容就是按键显示的内容 -Label控件: 用于显示用户不能编辑的文本或图像 - -``` - diff --git "a/\347\254\224\350\256\260.txt" "b/\347\254\224\350\256\260.txt" deleted file mode 100644 index 731f0d56ecb3a359e59d2f090b933474d7244460..0000000000000000000000000000000000000000 --- "a/\347\254\224\350\256\260.txt" +++ /dev/null @@ -1,101 +0,0 @@ -一、ASP.NET -ASP.NET功能 -多语言支持 -代码编译执行 -缓存机制 -服务器控件 -Web服务 -状态管理 -安全管理 -配置和部署 - -什么是IIS -1、同样是动态网页技术,ASP.NET就像JSP需要Tomcat服务器或者Apache服务器一样,ASP.NET也需要使用Web服务器作为其发布平台,一般使用IIS作为其Web服务器。IIS是Internet信息服务(Internet Information Server)的缩写,是微软的Internet服务器 - -2、IIS是Windows Servers 操作系统免费捆绑的组件 - -3、IIS是web应用程序运行的服务器 - - 二、页面对象 -Page指令 -| **属** **性** | **说** **明** | -| ------------------ | ------------------------------------------------------------ | -| AutoEventWireUp | 设置为True时,指定页面事件自动触发。这个属性的默认设置是True | -| Buffer | 设置为True时,支持HTTP响应缓存。这个属性的默认设置是True | -| ClassName | 指定编译页面时绑定到页面上的类名 | -| CodeFile | 引用与页面相关的后台编码文件 | -| CodePage | 指定响应的代码页面值 | -| ContentType | 把响应的HTTP内容类型定义为标准MIME类型 | -| Debug | 设置为True时,用调试符号编译页面 | -| EnableSessionState | 设置为True时,支持页面的会话状态,其默认设置是False | -| EnableTheming | 设置为True时,页面可以使用主题。其默认设置是False | -| EnableViewState | 确定是否为服务器控件保持页面的ViewState。默认值是True | -| **ErrorPage** | **为所有未处理的页面异常指定用于发送信息的****URL** | -| ---------------- | ------------------------------------------------------------ | -| Language | 定义内置显示和脚本块所使用的语言 | -| MasterPageFile | 带一个String值,指向页面所使用的master页面的地址。这个属性在内容页面中使用 | -| ResponseEncoding | 指定页面内容的响应编码 | -| Theme | 使用主题功能,把指定的主题应用于页面 | -| Title | 应用页面的标题。这个属性主要用于必须应用页面标题的内容页面,而不是应用master页面中指定内容的页面 | -| Trace | 设置为True时,激活页面跟踪,其默认值是False | -| TraceMode | 指定激活跟踪功能时如何显示跟踪消息。这个属性的设置可以是SortByTime或SortByCategory,默认设置是SortByTime | -| Transaction | 指定页面上是否支持事务处理。这个属性的设置可以是NotSupported、Supported、Required和RequiresNew,默认值是NotSupported | - -##### Page对象事件 - -``` -AbortTransaction -CommitTransaction -DataBinding -Disposed -Error -Init -Load -PreRender -Unload - -``` - -##### Page对象事件-2 - -``` -主页面事件的启动顺序 -PreInit -Init -InitComplete -PreLoad -Load -LoadComplete -PreRender -PreRenderComplete -Unload - -``` - -##### Page对象属性 - -| **属** **性** | **说** **明** | -| --------------- | ------------------------------------------------------------ | -| Application | 为当前Web请求获取Application,对于每个Web应用程序来说,只须一个该对象的实例。它是有所有访问该Web应用程序的客户端共享的 | -| EnableViewState | 指定当前页面上的服务器控件是否在页面请求之间保持ViewState。该值影响网页上的所有控件,同时取代控件自身的任何个人设置 | -| ErrorPage | 获取或设置错误页面,在发生未处理的页异常的事件时请求浏览器将被重定向到该页 | -| ID | 用于获取或设置Page类的特定实例的标识符 | -| IsPostBack | 获取一个值,该值指示页面是否为响应客户端回发而加载,或者它是否正被首次加载和访问 | -| IsVaild | 获取一个值,该值指示页面验证是否成功 | -| Request | 用于获取HttpRequest对象,此对象与从客户发送HTTP请求数据的当前页面关联 | -| Reponse | 用于获取HttpResponse对象,此对象与客户发送HTTP请求数据的当前页面关联 | -| Server | 对当前Server对象的引用 | -| Session | 用于获取ASP.NET提供的当前Session对象 | - - - - - - 跨页面传值 - -``` -步骤: -1.在Page1中使用IsPostBackUrl指定Page2 -2.在Page2中的Page_Load编写代码: - 1) 首先判断Page2页面是否有上一页,如果是没有那么Page.Previous == null - 2)其次使用Previous.FindControl()查找上一页的指定ID值 \ No newline at end of file