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. WBS功能分解

    WBS功能分解表格如下: 功能 子功能 二级子功能 预计花费时间 (小时) 实际花费时间(小时) 地图显示跑道 制作地图 获得开发权限key 1 2 将sdk导入程序 0.5 1   调试程序 1 2 ...

  2. String相关的问题

    基本事实:对于字符串常量,如果内容相同,Java认为它们代表同一个String对象.而用关键字new 调用的构造器,总是会创建新的对象,无论内容是否相同.字符串常量是放在常量池(或者叫常量缓冲区)里面 ...

  3. Qt之添加QLabel的点击事件

    QLabel功能为显示了一个字符串或者图片等信息,它本身没有click信号.也就不能够响应click点击事件,有什么办法来实现来,我们可以子类化QLabel,实现MouseXXXEvent.class ...

  4. mysql大数据分表后查询

    当数据量猛增的时候,大家都会选择库表散列等等方式去优化数据读写速度,举例说明: 1亿条数据,分100张表 1.首先创建100张表 $i=0;while($i<=99){echo "$n ...

  5. asp.net sqlite 当插入数据后的第一次访问会变的很慢!

    <add key="ConnectionStringSQLite" value="data source=|path|DB/XXX.db;Version=3;&qu ...

  6. linux下使用远程图形界面

    1. 用xrdp的方式(客户端就是windows下的远程桌面程序) http://jingyan.baidu.com/article/d3b74d64bdab5d1f76e60951.html 2. ...

  7. Window Azure ServiceBus Messaging消息队列技术系列2-编程SDK入门

    各位,上一篇基本概念和架构中,我们介绍了Window Azure ServiceBus的消息队列技术的概览.接下来,我们进入编程模式和详细功能介绍模式,一点一点把ServiceBus技术研究出来. 本 ...

  8. 我的第一个hadoop程序

    利用virtualbox+win的开发环境搭设好咯,在win下做开发,利用linux跑hadoop,伪分布式的. 上第一个程序 package org.apache.hadoop.examples; ...

  9. xutils3

    使用方法:https://github.com/wyouflf/xUtils3 http://blog.csdn.net/tyk9999tyk/article/details/53306035 .Ne ...

  10. REST WCF Service中的WebMessageBodyStyle

    这个参数是个枚举包括如下值: WebMessageBodyStyle.Bare WebMessageBodyStyle.Wrapped WebMessageBodyStyle.WrappedReque ...