asp.net客户端传递参数心得
客户端传送数据到服务器端有三种方法:
1.form
2.querystring
3.cookie
利用这些方式取得的数据在服务器端都是字典集合,如果要精确取到某个集合的值,则直接使用对应的集合的名称,三种方式对应的集合如下:
1.form:request.form
2.querystring:request.querystring
3.cookie:request.cookie
利用request.param则可以把三个集合集中起来,中间以","来分隔,所以如果数据中有","将会有分析的岐义出现。
利用request("itemName")也会把三个集合集中起来,但是他不会做string.join操作,只会把优先级最高且存在itemName项目的值取出来。经过测试,三种方式的优先级从 高到低为:
1.querystring
2.form
3.cookie
相关文档:
1.
此处提供的代码用来实现当asp.net
页面中的某个Button
被点击后disable
掉该页面中所有的Button
,从而防止提交延时导致的多次提交。基于之前的onceclickbutton
脚本.
//ASP.NET
中防止页面多次提交的代码:javascript< script
language="javascript"> < !-- function dis ......
前台:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
......
方法1:
比如建立一个名为cnlive,值为"123"的cookie
HttpCookie cookie = new HttpCookie["cnlive"];
cookie.Value = "123";
Response.AppendCookie(cookie);
取刚才写入的Cookie值:
HttpCookie cookie = Request.Cookies["cnlive"];
cookieValue = cookie.Value;
在一个Cookie中储存多个信息:
HttpCookie cookie ......
下载页面:
<a href="download.ashx?url=<%=Server.UrlEncode("说明.txt")%>">下载</a>
------------------------------------------------------------------------------
download.ashx
<%@ WebHandler Language="C#" Class="download" %>
using System;
using System.Web;
public ......
1.弹出对话框.
a. 弹出对话框:
C# codeClientScript.RegisterStartupScript(this.GetType(), "",
"<script>window.alert('该会员没有提交申请,请重新提交!')</script>");
b.转向指定页面
C# code Response.Write("
<script>window.location='http://www. ......