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 ...
随机推荐
- android adb命令
adb查看logcat adb logcat <TAG>:* *:S 查看指定TAG的Log adb查看最上层activity:linux: adb shell dumpsys activ ...
- PHP扩展开发及内核应用
目录中汉字部分代表已经翻译完成的章节,带链接的表示已经发布的,未待链接的表示正在校正即将发布的. PHP的生命周期 让我们从SAPI开始 PHP的启动与终止 PHP的生命周期 线程安全 小结 PHP变 ...
- 头疼:为什么chrome不能访问本地文件(带--disable-web-security --allow-file-access-from-files )
如题,寻求帮助! chrome 带参数启动 --disable-web-security --allow-file-access-from-files 照理应该可以加载本地文件,找遍google和英 ...
- QT 网络编程
#include "networkinformation.h" #include "ui_networkinformation.h" networkinform ...
- Android 获取渠道名称
直接看代码, //获取渠道名称public static String getChannelName(Activity ctx) { if (ctx == null) { return null; } ...
- Python—redis
一.redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sor ...
- PHP 微信分享
share.php <?php //公众号设置一下 JS接口安全域名,不要http,www的一级域名,比如http://www.baidu.com域名下的某个路径要分享,js安全域名中只需填上 ...
- 安装win7的那些事
由于win7系统只支持MBR格式的分区,如果强行将win7安装到UEFI分区方式的硬盘上将不能启动,所以,如果你要给别人的win8或者win10的OEM系统安装win7的话,记得先将重要数据备份出去, ...
- 关闭编辑easyui datagrid table
var rows = dg.datagrid('getRows'); for (var i = 0; i < rows.length; i++) { dg.datagrid( ...
- html(一)
一丶网页的主体结构 <html><head> <title>标题</title> //浏览器的标题</head><body> ...