Application - 全局公共变量组

存放位置:服务端

所有的访问用户都是访问的同一个变量

声明周期:永久

用法同session类似

viewstate-病例

因为http的无状态性,需要记录上一个页面的状态,因而需要一个viewstate记录上一个页面的状态,然后返回成相应的内容

纯HTML提交:

HTML界面:

要写action与method:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form action="Default.aspx" method="get">
货品名称:<input type="text" name="t1"/><br />
货品数量:<input type="text" name="t2"/><br />
单价:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="t3"/><br />
进货时间:<input type="text" name="t4"/><br />
联系电话:<input type="text" name="t5"/><br />
仓库号:&nbsp&nbsp&nbsp&nbsp
<select id="Select1" name="t6">
<option>g01</option>
<option>g02</option>
<option>g03</option>
</select> <br />
<input type="submit" value="提交" /> </form> </body>
</html>

实体类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; /// <summary>
/// goods 的摘要说明
/// </summary>
public class goods
{
public goods()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string goodsname { get; set; }
public string number { get; set; }
public string sprice { get; set; }
public DateTime intime { get; set; }
public string gtel { get; set; }
public string goodsbase { get; set; } }

数据访问类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient; /// <summary>
/// goodsdata 的摘要说明
/// </summary>
public class goodsdata
{
SqlConnection conn = null;
SqlCommand cmd = null;
public goodsdata()
{
conn = new SqlConnection("server=.;database=data0928;user=sa;pwd=123");
cmd = conn.CreateCommand();
}
public bool insert(goods g)
{
bool ok = false;
int count = ;
cmd.CommandText = "insert into goods values(@a,@b,@c,@d,@e,@f)";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@a",g.goodsname);
cmd.Parameters.AddWithValue("@b",g.number);
cmd.Parameters.AddWithValue("@c",g.sprice);
cmd.Parameters.AddWithValue("@d",DateTime.Now);
cmd.Parameters.AddWithValue("@e",g.gtel);
cmd.Parameters.AddWithValue("@f",g.goodsbase);
conn.Open();
count = cmd.ExecuteNonQuery();
conn.Close();
if (count > )
{ ok = true; }
return ok;
}
}

aspx界面:

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
goods g = new goods();
g.goodsname = Request["t1"];
g.number = Request["t2"];
g.sprice = Request["t3"];
g.intime = Convert.ToDateTime(Request["t4"]);
this.Title = g.intime.ToString();
g.gtel = Request["t5"];
g.goodsbase = Request["t6"]; bool ok = new goodsdata().insert(g);
if (ok)
{
Response.Write("<script>alert('添加成功')</script>"); }
}
}

application、viewstate、纯HTML提交方式的更多相关文章

  1. WebForm Application Viewstate 以及分页(功能性的知识点)

    Application: 全局公共变量组 存放位置:服务器 特点:所有访问用户都是访问同一个变量,但只要服务器不停机,变量一直存在于服务器的内存中,不要使用循环大量的创建Application对象,可 ...

  2. jquery提供的数据提交方式2-ajax

    以前介绍过ajax提交方式.但仅仅是个例子,今天将详细介绍jquery中的$.ajax,$.get,$.post方法. 一,首先介绍$.ajax方法参数(以下参数来自:http://www.cnblo ...

  3. 三种POST和GET的提交方式

    向服务器提交数据有两种方式,post和get.两者的区别主要有三点,安全性.长度限制.数据结构.其中get请求安全性相比较而言较差,数据长度受浏览器地址栏限制,没有方法体.两种都是较为重要的数据提交方 ...

  4. 四种常见的 POST-------- content-type数据提交方式

    HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TRACE.CONNECT 这几种.其中 POST 一般用来向服务端提交数据,本文 ...

  5. POST不同提交方式对应的Content-Type,及java服务器接收参数方式

    POST不同提交方式对应的Content-Type,及java服务器接收参数方式 注:本博客参考了网上的文章结合自己工作总结后所写,主要用于记录自己工作所得,如有错误请批评指正. 简介: Conten ...

  6. 利用 ajax自定义Form表单的提交方式

    需求场景:有时候单纯的form表单无法向后端传递额外的参数 比如需要action传递js异步生成的参数 ,form表单默认的action就无法满足需求,这时就需要我们自定义form表单的提交方式. h ...

  7. 渗透常用dos命令,http协议及数据提交方式。 hack 某某

    dir查看目录 cd 切换目录 strat www.xxx.com   打开网页 del 删除文件 cls 清屏幕命令 ipconfig  查看ip地址 netstat -an   显示网络连接.路由 ...

  8. POST—常见的4种提交方式

    HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TRACE.CONNECT 这几种.其中,POST 一般用来向服务端提交数据,本文 ...

  9. HTML提交方式post和get区别(实验)

    HTML提交方式post和get区别(实验) 一.post和get区别 get提交,提交的信息都显示在地址栏中. post提交,提交的信息不显示地址栏中,显示在消息体中. 二.客户端代码 <!D ...

随机推荐

  1. DI依赖注入/IOC控制反转

    DI依赖注入# 啥都不说,直接上代码 <?php class UserController { private $user; function __construct(UserModel $us ...

  2. Python中递归的最大次数

    实际应用中遇到了一个python递归调用的问题,报错如下: RuntimeError: maximum recursion depth exceeded while calling a Python ...

  3. Db2数据库的备份和恢复

    DB2数据库备份与恢复 1.    备份 1.1离线备份(必须在数据库所在PC机进行操作) STEP 1 连接到要备份的数据库 C:\Documents and Settings\Administra ...

  4. 【转载】jQuery动画连续触发、滞后反复执行解决办法

    转载: http://www.cnblogs.com/yuejin/archive/2012/12/18/2822595.html jQuery中slideUp .slideDown.animate等 ...

  5. XP 安装Oralce 10g 数据库

    今天使用XP新建一个新数据库,下面是自己的操作方法, 电脑版本型号:Microsoft Windows XP Professional 版本 2002 Service Pack 3 Oracle版本型 ...

  6. 亲手使用Sencha Touch + phonepag开发Web APP随笔 -- 第一个APP

    参考博文: [Phonegap+Sencha Touch] 移动开发1.准备工作 [Phonegap+Sencha Touch] 移动开发2.PhoneGap/Cordova初步使用   经过差不多1 ...

  7. Delphi Json

    superobject.pas单元对json的解析非常方便, 力荐 下面演示对如下json的解析 { ", "memo": "S.H.E 004" } ...

  8. 推荐一篇好文:OSG OSGearth vs2010编译

    链接:http://weibo.com/p/2304189447a8480102v2c2 此文作者把用到的相关代码包放在:http://pan.baidu.com/s/1qW9a4zU 按照步骤操作完 ...

  9. js通过隐藏iframe修改session值

    js:function selects(id, ss) { window.frames["UpSession"].window.location.href = "../U ...

  10. yield 用法分析

    yield 关键字向编译器指示它所在的方法是迭代器块.编译器生成一个类来实现迭代器块中表示的行为.在迭代器块中,yield 关键字与 return 关键字结合使用,向枚举器对象提供值.这是一个返回值, ...