c# asp.net 获取客户端表单的数据
在web程序中,经常会使用在一个网页使用其他网页提交的数据信息,这里可以使用Request内置对象来完成,来获取用户提交的信息,根据客户端提交数据方式的不同,Request对象分别使用Form和QueryString集合属性来获取数据。下面是两种集合获取方式的不同点:通过Form获取数据时在form属性中简单的添加action=“跳转的网页地址”,<form. ID="id号 " runat=“sever” action=“要跳转的网页URL”> </form>,该传参方式是隐式的,不容易暴露;另一种方式是通过get方法提交表单数据,或页面导向通过“URL?Parameter=Value”格式传递参数值时,即使用Request对象QueryString属性获取传递过来的信息,这个传参方式一般不建议使用,因在URL之后,所以容易在浏览器暴露参数,容易遭受黑客的攻击,再者是URL的字节数有限,即传递的参数有限,所以不建议使用QueryString。
这里需要建立两个web程序页,第一个Default.aspx页中运用各种控件,第二个是在get-form.aspx的后台代码中在页面加载的时候获得Default.aspx页中,用户提交的信息数据。
Default.aspx的html代码:
view source
< id="highlighter_304109_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash">
print?
01
<PREclass=brush:csharp><%@ Page Language="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="form._Default"%>
02
03
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
04
05
<html xmlns="http://www.w3.org/1999/xhtml">
06
<head runat="server">
07
<title>无标题页</title>
08
</head>
09
<body>
10
<form. id="Form1"action="get_form.aspx"method="post">
11
<div style="text-align:center">
12
填写用户信息
13
<hr style="size:50%"/>
14
&
相关文档:
Unix时间戳最小单位是秒,开始时间为格林威治标准时间1970-01-01 00:00:00
ConvertIntDateTime方法的基本思路是通过获取本地时区表示Unixk开始时间,加上Unix时间值(即过去的秒数).
ConvertDateTimeInt方法的基本思路是通过刻度数差,再把刻度数转换为秒数,当然要说明的是,我这里返回的是double类型,意义上并非是真 ......
<%
set conn= server.createobject("ADODB.connection")
conn.open "driver={sybase driver 10};"
"srvr=SYBASE;"
"UID=sa;"
"pwd=sybase;"
sql="select no from tab_st ......
Backup.aspx
protected void Button1_Click(object sender, EventArgs e)
{
string path = Server.MapPath("") + @"\Backup";
if (!Directory.Exists(path))
......
static void Main(string[] args)
{
string connstr = "Data Source=***;user=system;password=***;";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
string orclstr="insert into SYS.A_MODULE values('03','查看生产任务','查看生产任务进度')";
......
//post请求
string name = Request["name"].toString();
string name =Request.Form.Get("name").toString();
//get请求
string name = Request.QueryString["name"].toString();
但我发现 无论是否是post与get传值都可用
string name = Request["name"].toString();
表单提交中get和post方式的区别归� ......