【ASP.NET】万水千山总得实践 --练习实践篇

在没看之前,我不知道如何和网页进行动态交互;在看了之后,我发现自己知道的真心很少,我仅有的知识根本支撑不起想实现的例子。且学且实践吧。

先安利一波有关实践的基础知识

(1)ASP.NET对象

对象描述
Request该对象用于检索从浏览器向服务器所发送的请求中的信息。在按下“提交”按钮时,Request对象将读取和提取通过HTTP请求发送的参数。在用户提交表单时,包含在输入空啊金中的数据将与表单一起被发送。
Response该对象用于将数据从服务器发送回浏览器。
ApplicationApplication 对象用于共享应用程序级信息。即,维护整个应用程序的一组变量,这些变量可以由所有访问应用程序的用户共享。
Session该对象用于存储在多个页面调用之间特定用户的信息。
Server该对象用于访问服务器上的资源。例如,访问在服务器上创建和安装的组件。
ObjectContext该对象用于控制事务处理。在使用Microsoft Transaction Server 时,该对象可用于提交或终止由ASP.NET脚本启动的事务。

(2)对象的方法

(3)提交的两种方法: get & post

上面 表单的提交方法是 post, 数据作为整体提交

下面 表单的提交方法是 get  将数据单独,放在URL,用符号进行连接

(3) 页面跳转 

     一般用     Response.Redirect("网页.aspx") ;

    form 标签中的数据提交的时候,用 action = " ... ... " 中的文件进行处理。

<form name="form1" method="post" || "get“  action = "文件.aspx">

... ...

</form>

(4) 控件类型

 

 

(5)例子

Page.IsPostBack 用于判断是否是第一次载入该网页。

第一阶段的学习,未完待续 ... ...

命名变量,变量计算等(WindowsFormsApplication1): using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text="hello"; string teststring="hello, world!"; //定义变量 textBox1.Text = teststring; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { int testint1 = 1000; //定义变量 int testint2 = 60; testint2 += 60; testint1 /= 2; textBox1.Text = Convert.ToString(testint1 + testint2); //变量相加 textBox2.Text = Convert.ToString(testint1 % testint2); //变量取余数 textBox3.Text = Convert.ToString( testint2); //取最终变量数 textBox4.Text = Convert.ToString(testint1); //取最终变量数 textBox5.Text = Convert.ToString(--testint1); //取自减一 textBox6.Text = Convert.ToString(++testint1); //取自加以 textBox7.Text = Convert.ToString(testint1--); //取自减一 textBox8.Text = Convert.ToString(testint1); //取自减一 textBox9.Text = "\"hello, \n world!\""; //换行符和转移符 textBox10.Text = testint1 > testint2 ? "大于" : "不大于"; // > 的选择 textBox11.Text = testint1 == testint2 ? "相等" : "不相等"; // == 的选择 textBox12.Text = testint1 != testint2 ? "不相等" : "相等"; // != 的选择 Boolean testboolean = true; label1.Text = Convert.ToString(testboolean); label2.Text = Convert.ToString(!testboolean); label3.Text = Convert.ToString(6 == 3 & 3 > 6); // 需要两个都满足是true,否则false label4.Text = Convert.ToString(6 != 3 & 3 6); // 需要两个都满足或都不满足是false,否则true textBox13.Text = Convert.ToString(10 <> 3); //二进制的计算 } private void textBox6_TextChanged(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } private void textBox13_TextChanged(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { int testint1 = 1; int testsum = 0; while (testint1 60) //if语句 { textBox15.Text = "大于60"; } else if (testint > 80) { textBox15.Text = "大于80"; } else if (testint > 200) { textBox15.Text = "小于200"; } textBox16.Text = "好的"; goto hello; //goto语句 hello: textBox16.Text = "hello"; } } }
评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值