时间:2011-06-21 10:49来源:未知 作者:admin 点击:25次 - - 1.在Page_Load事件添加以下代码: protected void Page_Load(object sender, EventArgs e) { string name = "大气象"; string age = "27"; Response.Write("你的姓名是:" + name + "<br>" + "你的年龄是:" + age + "<br>"); Response.Write("你使用的是" + Request.RequestType + "方式传送数据"); //第一次显示时,是直接在浏览器中输入url,所以显示get方式. } 。
等价方法
Request.QueryString["b"]等价于Request["b"]
if (this.Request.QueryString["b"] == null)
1.放两个textBox一个Button ID分别为:name,age,Button1 添加单击事件如下: protected void Button1_Click(object sender, EventArgs e) { //使用Post方式传递数据. string name = Request.Form["name"];//取得表单中ID是name的控件的值. string age = Request.Form["age"]; Response.Write("你的姓名是:" + name + "<br>" + "你的年龄是:" + age + "<br>"); Response.Write("你使用的是" + Request.RequestType + "方式传送数据"); } 2.用Request获取服务器信息.服务器环境变量. 为按钮添加事件响应如下: Response.Write("当前网页虚拟路径是:" + Request.ServerVariables["url"]); Response.Write("<br>实际路径:" + Request.ServerVariables["path_translated"]); Response.Write("<br>服务器名:" + Request.ServerVariables["server_name"]); Response.Write("<br>服务器IP:" + Request.UserHostAddress); //另一种方面 Response.Write("<br>当前网页虚拟路径是:" + Request.RawUrl); Response.Write("<br>实际路径:" + Request.PhysicalPath); 3.用Request获取用户信息.浏览器环境变量. 为按钮添加事件响应如下: Response.Write("<br>这个浏览器是否支持背景音乐:" + Request.Browser.BackgroundSounds); Response.Write("<br>这个浏览器是否支持框架:" + Request.Browser.Frames); Response.Write("<br>客户用的是什么系统:" + Request.Browser.Platform);
本篇文章来源于 www. 原文链接:http://www./html/aspnet/objects/2011/0621/4121.html
|