application、viewstate、纯HTML提交方式
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 />
单价:        <input type="text" name="t3"/><br />
进货时间:<input type="text" name="t4"/><br />
联系电话:<input type="text" name="t5"/><br />
仓库号:    
<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提交方式的更多相关文章
- WebForm Application Viewstate 以及分页(功能性的知识点)
Application: 全局公共变量组 存放位置:服务器 特点:所有访问用户都是访问同一个变量,但只要服务器不停机,变量一直存在于服务器的内存中,不要使用循环大量的创建Application对象,可 ...
- jquery提供的数据提交方式2-ajax
以前介绍过ajax提交方式.但仅仅是个例子,今天将详细介绍jquery中的$.ajax,$.get,$.post方法. 一,首先介绍$.ajax方法参数(以下参数来自:http://www.cnblo ...
- 三种POST和GET的提交方式
向服务器提交数据有两种方式,post和get.两者的区别主要有三点,安全性.长度限制.数据结构.其中get请求安全性相比较而言较差,数据长度受浏览器地址栏限制,没有方法体.两种都是较为重要的数据提交方 ...
- 四种常见的 POST-------- content-type数据提交方式
HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TRACE.CONNECT 这几种.其中 POST 一般用来向服务端提交数据,本文 ...
- POST不同提交方式对应的Content-Type,及java服务器接收参数方式
POST不同提交方式对应的Content-Type,及java服务器接收参数方式 注:本博客参考了网上的文章结合自己工作总结后所写,主要用于记录自己工作所得,如有错误请批评指正. 简介: Conten ...
- 利用 ajax自定义Form表单的提交方式
需求场景:有时候单纯的form表单无法向后端传递额外的参数 比如需要action传递js异步生成的参数 ,form表单默认的action就无法满足需求,这时就需要我们自定义form表单的提交方式. h ...
- 渗透常用dos命令,http协议及数据提交方式。 hack 某某
dir查看目录 cd 切换目录 strat www.xxx.com 打开网页 del 删除文件 cls 清屏幕命令 ipconfig 查看ip地址 netstat -an 显示网络连接.路由 ...
- POST—常见的4种提交方式
HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TRACE.CONNECT 这几种.其中,POST 一般用来向服务端提交数据,本文 ...
- HTML提交方式post和get区别(实验)
HTML提交方式post和get区别(实验) 一.post和get区别 get提交,提交的信息都显示在地址栏中. post提交,提交的信息不显示地址栏中,显示在消息体中. 二.客户端代码 <!D ...
随机推荐
- python3爬取网页
爬虫 python3爬取网页资源方式(1.最简单: import'http://www.baidu.com/'print2.通过request import'http://www.baidu.com' ...
- IOS轮播图
轮播图播放的主要技术在于: cell的封装.这里采用UICollectionViewCell实现. #import <UIKit/UIKit.h> @interface CircleVie ...
- JDBC基础与连接sql2012
JDBC简介 JDBC全称为:Java Data Base Connectivity(java数据库连接),它主要由接口组成. 组成JDBC的2个包: java.sql javax.sql 以上2个包 ...
- 笔记本中的archlinux调节亮度
参考了archlinux的wiki:https://wiki.archlinux.org/index.php/Backlight 说一下情况:/sys/class/backlight/acpi_vid ...
- html5,加密元素
<form action=""> 账号:<input type="text" name="user"> ...
- BabelMap 9.0.0.3 汉化版(2016年12月27日更新)
软件简介 BabelMap 是一个免费的字体映射表工具,可辅助使用<汉字速查>程序. 该软件可使用系统上安装的所有字体浏览 Unicode 中的十万个字符,还带有拼音及部首检字法,适合文献 ...
- CheckBox 半选中状态
<input type='checkbox' />可以半选中,这个特性,很多浏览器都支持,包括Firefox,Chrome和IE 用 input.indeterminate 这个属性来获取 ...
- iOS8.3发布了Swift 1.2带来哪些新变化
苹果前几日在面向开发者推送iOS 8.3 Beta的同时,还发布了版本号为6D520o的Xcode 6.3 Beta,其中便包含了iOS 8.3 Beta和OS X v10.10 SDK,并进一步提升 ...
- npm 安装本地包
npm install ../xxx 就行 如果报错,比如 1`Refusing to install as a dependency of itself 说明你的本地模块没npm init ,也就 ...
- memcache基础知识
memcached的内存存储机制 Memcached默认情况下采用了名为Slab Allocator的机制分配.管理内存.在该机制出现以前,内存的分配是通过对所有记录简单地进行malloc和free来 ...