知识点:

Request - 获取请求对象

  专门用来接传递过来的值

  Request["key"](李献策lxc)

  1、获取地址栏传递过来的值 get

  2、获取表单传递过来的参数值 post

  例:TextBox1.Text = Request["abc"];

    http://localhost:1806/Default.aspx?abc=2017你好

  注:& 传多个值

QueryString - get提交方式/地址栏传值

  地址栏后面接 ?key=value&key=value

  优点:不占用内存,速度快;可以传递多个值

  缺点:安全性差

Reponse - 响应请求对象(李献策lxc)

  Reponse.Redirect("地址")  - 页面重定向,只能在本页面打开其他页面(在网页顶部打印文字)

  Reponse.Write("JS代码") - 打印,若是string文字则显示在最上方(弹窗)

功能:

1、Request - 获取请求对象

如何用textbox1取值?

后台代码:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = Request["abc"];
}
}

地址栏中地址后面加英文状态下的 ?key=value

后台代码:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = Request["abc"];
TextBox1.Text += Request["eee"];
}
}

2、QueryString - get提交方式/地址栏传值

如何打开另一个页面?

<body>
<form id="form1" runat="server"> <a href="Default.aspx">打开主页面</a> </form>
</body>

如何进行传值?

<body>
<form id="form1" runat="server"> <a href="Default.aspx?abc=2017年第一天">打开主页面</a> </form>
</body>

3、Reponse - 相应请求对象

点击按钮跳转页面

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;
}
//点击按钮跳转页面
void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
}

如何传值(李献策lxc)

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;
}
//点击按钮跳转页面
void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx?abc=你好2017!");
}
}

Response 扩展

1、在网页顶部打印文字

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;
}
//点击按钮跳转页面
void Button1_Click(object sender, EventArgs e)
{
Response.Write("今天是2017年第一天!");
}
}

输出的文字在最上面,不在代码内

2、弹窗

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += Button1_Click;
}
//点击按钮跳转页面
void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script>alert('你好2017!');</script>");
}
}

C#-WebForm-Request、Response、QueryString的更多相关文章

  1. 第十五节:HttpContext五大核心对象的使用(Request、Response、Application、Server、Session)

    一. 基本认识 1. 简介:HttpContext用于保持单个用户.单个请求的数据,并且数据只在该请求期间保持: 也可以用于保持需要在不同的HttpModules和HttpHandlers之间传递的值 ...

  2. @ModelAttribute设置request、response、session对象

    利用spring web提供的@ModelAttribute注解 放在类方法的参数前面表示引用Model中的数据 @ModelAttribute放在类方法上面则表示该Action类中的每个请求调用之前 ...

  3. Java中都通用文件下载(ContentType、文件头、response、out四步骤)

    Java中都通用文件下载(ContentType.文件头.response.out四步骤) 新浪微博:IT国子监(记得关注噢) http://weibo.com/itguozijian   我们就直接 ...

  4. HttpContext对象下的属性Application、Cache、Request、Response、Server、Session、User

    概述: HttpContext封装关于单个HTTP请求的所有HTTP特定信息. HttpContext基于HttpApplication的处理管道,由于HttpContext对象贯穿整个处理过程,所以 ...

  5. C#-WebForm-Request、Response、QueryString、Repeater删

    知识点: Request - 获取请求对象 专门用来接传递过来的值 Request["key"](李献策lxc) 1.获取地址栏传递过来的值 get 2.获取表单传递过来的参数值 ...

  6. ASP.NET中的Request、Response、Server对象

    Request对象 Response.Write(Request.ApplicationPath) //应用根路径 Request.AppRelativeCurrentExecutionFilePat ...

  7. egg 官方文档之:框架扩展(Application、Context、Request、Response、Helper的访问方式及扩展)

    地址:https://eggjs.org/zh-cn/basics/extend.html Application app 对象指的是 Koa 的全局应用对象,全局只有一个,在应用启动时被创建. 访问 ...

  8. ASP内置对象—Request、Response 、Server、Application 、ObjectContent (二)

    Response (应答)对象 Request 对象.用于在HTTP请求期间,訪问不论什么client浏览器传递给server的信息,包含通过URL传递的參数信息.使用GET方法或POST方法传递的H ...

  9. JSP三大常用对象request、response、session

    1.request对象 客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求, 然后做出响应.它是HttpServletRequest类的实例. 序号方法说明 objectgetA ...

随机推荐

  1. Common issue on financial information exchange (FIX) Connectivity[z]

    FIX Protocol Session Connectivity Hi guys, in this post I would like share my experience with financ ...

  2. gen_empty_obj算子的作用

    gen_empty_obj 算子解释: Create an empty object tuple. 其算子签名为: gen_empty_obj( : EmptyObject : : ) 那么有人要问: ...

  3. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList

    Array: def x = new String[5] x[0] = "India" x[1] = "USA" x[2] = "Korea" ...

  4. VS2010+SVN

    小乌龟版本用1.6,用1.8时老报错SVN是2.06, SVN Server是2.1.9

  5. 利用Word发布文章到博客

    目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...

  6. ZOJ3767 Elevator 2017-04-13 23:32 37人阅读 评论(0) 收藏

    Elevator Time Limit: 2 Seconds      Memory Limit: 65536 KB How time flies! The graduation of this ye ...

  7. 面试经验之——HE集团,YZ科技

    上周去了HE集团面试,该集团是做车辆辅助驾驶系统的,最终目标瞄准的是自动驾驶,加上再之前在YZ科技的面试经验,有些关于车辆驾驶上的心得想聊聊. 首先说说两个企业的面试情况吧.YZ科技中的两个技术聊天都 ...

  8. 基于Extjs的web表单设计器 第一节

    前面一节介绍了表单设计器的背景和最终的大概样式,本节主要介绍表单设计器的需求及功能设计. 在讲需求之前先明确几个常用的概念: 主表或者卡片表——具有多行多列的一个区域的控件块,如下图所示. 明细表—— ...

  9. Discuz showmessage函数解析[转]

    函数相关文件 \source\function\function_core.php\source\function\function_message.php ## 函数解释 /** * 显示提示信息 ...

  10. 自定义Team Foundation Server (TFS) 与Project Professional的集成字段

    用户可以象使用Office Excel一样,使用Project Professional连接TFS,将数据下载到本地修改,并且发布到TFS服务器上,如果你习惯使用Project来计划你的项目,那么Pr ...