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. WPF绑定xml数据源

    1.界面 <UserControl x:Class="HKDCMS.Client.Demo.UIViews.UIControls.AboutUsControl" xmlns= ...

  2. C++动态加载DLL调用方法

    一.构建DLL路径 char szTmp[_MAX_PATH]; char* szPath = getcwd(szTmp, _MAX_PATH);//获取当前工作目录  //构建dll路径  strc ...

  3. 【C# 基础应用】我的第一个App,不容易——随机生成小人网站,asp.net core

    Index page Welcome page 生成很多不同的小人哦~我是如何实现这么stupid but interesting的程序呢?我用了ASP.NET Core 画小人的话,用了一个很stu ...

  4. deep learning...深入学习深度学习 --工具篇

    Caffe( http://caffe.berkeleyvision.org/ )是一个清晰而高效的深度学习框架,其作者是博士毕业于UC Berkeley的贾扬清( http://daggerfs.c ...

  5. Python 的安装与配置(Windows)

    Python2.7安装配置 python的官网地址:https://www.python.org/ 我这里下载的是python2.7.12版本的 下载后点击安装文件,直接点击下一步知道finally完 ...

  6. sql查询指定表外键约束

    //////////////////查询指定表外键约束select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外 ...

  7. OC的总结 ***希望对大家有帮助*** ---高小杰

    1.  NSLog           是Foundation提供的一个输出函数,它的功能非常强大,不仅可以输出字符串,还可以输出各种对象,到后面程序还会见到大量的使用NSLog()函数. 2.  N ...

  8. Android 常用操作

    0.android studios使用介绍 使用介绍 android studio 常用小技巧 网址 1.怎么样添加第三方库 方法一: 第一步:将第三方库以module的形式导入 第二步:选中要导入第 ...

  9. Bootstrap栅格系统详解,响应式布局

    Bootstrap栅格系统详解 栅格系统介绍 Bootstrap 提供了一套响应式.移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列. 栅格系统用于通 ...

  10. github开发

    从0开始学习 GitHub 系列之「初识 GitHub」 从0开始学习 GitHub 系列之「加入 GitHub」 从0开始学习 GitHub 系列之「Git 速成」 从0开始学习 GitHub 系列 ...