04Add.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>新增班级</title>
<style type="text/css">
#tbList {
border:1px solid #0094ff;
border-collapse:collapse;
width:300px;
margin:50px auto;
}
#tbList th,td{
border:1px solid #0094ff;
padding:5px;
}
</style>
</head>
<body>
<form method="post" action="04Add.ashx">
<table id="tbList">
<tr>
<td>班级名称:</td>
<td><input type="text" id="txtName" name="txtName"/></td>
</tr>
<tr>
<td>班级人数:</td>
<td><input type="text" id="txtCount" name="txtCount" /></td>
</tr>
<tr>
<td colspan="">
<input type="submit" value="确定" />
<input type="button" id="btnCancel" value="取消" onclick="window.location='01List.ashx'" />
</td>
</tr>
</table>
</form>
</body>
</html>

04Add.ashx

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web; namespace AspNetAshx
{
/// <summary>
/// _04Add 的摘要说明
/// </summary>
public class _04Add : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html"; //1.获取用户表单post提交的数据
string strName = HttpContext.Current.Request.Form["txtName"].Trim();
string strCount = HttpContext.Current.Request.Form["txtCount"];
//2.验证数据
if (string.IsNullOrEmpty(strName) || !CommonHelper.IsNum(strCount))
{
CommonHelper.WriteJs("对不起,您输入的数据格式错误~请仔细检查~~", "04Add.html");
}
else
{
//3.更新到数据库中
SqlParameter[] paras = {
new SqlParameter("Cname",strName),
new SqlParameter("CCount",strCount)
};
int res = SqlHelper.ExcuteNoneQuery("insert into Classes (CName,CCount) values(@Cname,@CCount)", paras);
if (res > )
{
CommonHelper.WriteJs("新增成功~!", "01List.ashx");
}
else
{
CommonHelper.WriteJs("新增失败~!如果您是美女,请联系管理员~~~qq:111111", "04Add.html");
}
}
} public bool IsReusable
{
get
{
return false;
}
}
}
}

最新文章

  1. iOS常见算法(二分法 冒泡 选择 快排)
  2. IDOC、ALE、EDI三者之间的区别于联系
  3. [置顶] c++类的继承(inheritance)
  4. 转载:linux capability深入分析
  5. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;springSessionRepositoryFilter&#39; is defined
  6. 红黑树-Python实现
  7. rabbitmq(中间消息代理)在python中的使用
  8. js一些梳理
  9. Java_延迟操作
  10. TabLayout和ViewPager
  11. MVC与单元测试实践之健身网站(五)-系统信息、前台入口
  12. [日常工作] Inspur 服务器安装ESXi的简单过程
  13. modelform save
  14. springboot form 提交集合 list
  15. Educational Codeforces Round 57 (Rated for Div. 2)
  16. Linux系统中时间区域和API
  17. 咏南中间件增加HTTPS.SYS支持
  18. SCOM发送邮件通知
  19. python3_json模块使用与字符编码问题
  20. NOIP2015 T4 推销员 贪心+堆优化

热门文章

  1. markdown 转 pdf 方法
  2. iOS: UUID and SSKeyChain
  3. Solr with Apache Tomcat
  4. 学习使用资源文件[11] - DLL 中的资源文件
  5. ASP.NET MVC自定义验证Authorize Attribute(包含cookie helper)
  6. 怎样用Javascript定义一个类
  7. jQuery为动态生成的select元素添加事件的方法
  8. ChemOffice Professional 16.0新增了哪些功能
  9. ios 显示代码块(show the code snippet library)
  10. Python 解压缩Zip和Rar文件到指定目录