热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ajax版学生管理

aspx:<%@PageLanguageC#AutoEventWireuptrueCodeFileajax.aspx.csInheritsajax%>&

aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajax.aspx.cs" Inherits="ajax" %>



"http://www.w3.org/1999/xhtml">
"server">
"Content-Type" cOntent="text/html; charset=utf-8" />


"CSS/StyleSheet.css" rel="stylesheet" />



"form1" runat="server">
"button" value="刷新" id="aa11" />
"button" value="添加" id="TJ" />
<%--登录弹窗--%>
<%--修改弹窗--%>
"tc" class="tc">
"tc-top" class="tc-top">
学生信息修改

"tc-main" class="tc-main">

class="divc">
class="divcc1">编号:

class="divcc2">
"tids" runat="server" ReadOnly="True">


class="divc">
class="divcc1">姓名:

class="divcc2">
"tname" runat="server">


class="divc">
class="divcc1">性别:

class="divcc2">
"tsex" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
"" Value="true">
"" Value="false">



class="divc">
class="divcc1">生日:

class="divcc2">
"tbirthday" runat="server">


class="divc">
class="divcc1">民族:

class="divcc2">
"DropDownList1" runat="server">


class="divc">
class="divcc1">班级:

class="divcc2">
"DropDownList2" runat="server">


class="divc">
class="divcc1">成绩:

class="divcc2">
"tscore" runat="server">



"tc-bottom" class="tc-bottom">
"tcbtn1();" id="tc-btn1" class="tc-btn1">
修改



"tc-zz" class="tc-zz">

<%--添加弹窗--%>
"tc1" class="tc">
"tc-top1" class="tc-top">
学生信息添加

"tc-main1" class="tc-main">
class="divc">
class="divcc1">姓名:

class="divcc2">
"tname1" runat="server">


class="divc">
class="divcc1">性别:

class="divcc2">
"tsex1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
"" Value="true" Selected="True">
"" Value="false">



class="divc">
class="divcc1">生日:

class="divcc2">
"tbirthday1" runat="server">


class="divc">
class="divcc1">民族:

class="divcc2">
"DropDownList11" runat="server">


class="divc">
class="divcc1">班级:

class="divcc2">
"DropDownList22" runat="server">


class="divc">
class="divcc1">成绩:

class="divcc2">
"tscore1" runat="server">



"Div4" class="tc-bottom">
"tcbtn2();" id="tcbtn2" class="tc-btn1">
添加



"tc-zz1" class="tc-zz">


<%-- 展示内容--%>
"width: 1000px; position: relative; margin: 0 auto; background-color: green; text-align: center;">

"color: white;">










"tt">
编号 姓名 性别 生日 民族 班级 成绩 操作






View Code

css:

.tc {
position:
fixed;
width: 400px;
left:
50%;
margin
-left: -200px;
top:
-600px;
border: 1px solid navy;
box
-shadow: 0 0 10px black;
z
-index: 1001;
background
-color: white;
}

.tc
-top {
width:
100%;
height: 30px;
background
-color: navy;
color: white;
font
-size: 18px;
font
-weight: bold;
text
-align: center;
line
-height: 30px;
}

.tc
-main {
padding: 20px;
text
-align: center;
}

.tc
-bottom {
position: relative;
width:
100%;
height: 40px;
}

.tc
-btn1 {
position: absolute;
top: 5px;
left:
50%;
margin
-left: -50px;
width: 100px;
height: 30px;
background
-color: navy;
color: white;
text
-align: center;
line
-height: 30px;
cursor: pointer;
}

.tc
-zz {
position:
fixed;
top: 0px;
left: 0px;
width:
100%;
height:
100%;
background
-color: black;
opacity:
0.3;
display: none;
z
-index: 1000;
}

.divc {
height: 50px;
width:
100%;
}

.divcc1 {
text
-align: right;
height: 50px;
width:
30%;
float: left;
}

.divcc2 {
text
-align: left;
height: 50px;
width:
70%;
float: left;
}
View Code

ashx:

1刷新:

 public void ProcessRequest(HttpContext context)
{
StringBuilder sb
= new StringBuilder();
sb.Append(
"[");
using (StudentsDataClassesDataContext con = new StudentsDataClassesDataContext())
{
List
ss = con.Stu.ToList();
int a = ss.Count;
int cc = 0;
foreach (Stu s in ss)
{
if (s == null) continue;
cc
++;
if (cc < a)
{ sb.Append(
"{\"ids\":\"" + s.Ids + "\",\"name\":\"" + s.Name + "\",\"sex\":\"" + s.Sexx + "\",\"birthday\":\"" + s.Birth + "\",\"nation\":\"" + s.NName + "\",\"class\":\"" + s.CName + "\",\"score\":\"" + s.Score + "\"},"); }
if (cc == a)
{ sb.Append(
"{\"ids\":\"" + s.Ids + "\",\"name\":\"" + s.Name + "\",\"sex\":\"" + s.Sexx + "\",\"birthday\":\"" + s.Birth + "\",\"nation\":\"" + s.NName + "\",\"class\":\"" + s.CName + "\",\"score\":\"" + s.Score + "\"}"); }
}

}
sb.Append(
"]");
context.Response.Write(sb);
context.Response.End();
}
View Code

2.修改1:

tringBuilder sb = new StringBuilder();
sb.Append(
"[");
using (StudentsDataClassesDataContext con = new StudentsDataClassesDataContext())
{
string s1 = context.Request["ids"];
Stu sa
= con.Stu.Where(r => r.Ids.ToString() == s1).FirstOrDefault();
if (sa != null)
sb.Append(
"{\"ids\":\"" + sa.Ids + "\",\"name\":\"" + sa.Name + "\",\"sex\":\"" + sa.Sex + "\",\"birthday\":\"" + Convert.ToDateTime(sa.Birthday).ToString("yyyy-MM-dd") + "\",\"nation\":\"" + sa.NationCode + "\",\"class\":\"" + sa.ClassCode + "\",\"score\":\"" + sa.Score + "\"}");
}
sb.Append(
"]");
context.Response.Write(sb);
context.Response.End();
View Code

修改2:

StringBuilder sb = new StringBuilder();
sb.Append(
"[");
string a = context.Request["ids"];
string b = context.Request["name"];
string c = context.Request["sex"];
string d = context.Request["birthday"];
string e = context.Request["nation"];
string f = context.Request["class"];
string g = context.Request["score"];
using (StudentsDataClassesDataContext con = new StudentsDataClassesDataContext())
{
Stu s
= con.Stu.Where(r => r.Ids.ToString() == a).FirstOrDefault();
if (s != null)
{
s.Name
= b;
s.Sex
= Convert.ToBoolean(c);
s.Birthday
= Convert.ToDateTime(d);
s.NationCode
= e;
s.ClassCode
= f;
s.Score
= Convert.ToInt32(g);
con.SubmitChanges();
}
List
ss = con.Stu.ToList();
int a1 = ss.Count;
int cc = 0;
foreach (Stu s1 in ss)
{
cc
++;
if (cc < a1)
{ sb.Append(
"{\"ids\":\"" + s1.Ids + "\",\"name\":\"" + s1.Name + "\",\"sex\":\"" + s1.Sexx + "\",\"birthday\":\"" + s1.Birth + "\",\"nation\":\"" + s1.NName + "\",\"class\":\"" + s1.CName + "\",\"score\":\"" + s1.Score + "\"},"); }
if (cc == a1)
{ sb.Append(
"{\"ids\":\"" + s1.Ids + "\",\"name\":\"" + s1.Name + "\",\"sex\":\"" + s1.Sexx + "\",\"birthday\":\"" + s1.Birth + "\",\"nation\":\"" + s1.NName + "\",\"class\":\"" + s1.CName + "\",\"score\":\"" + s1.Score + "\"}"); }
}
sb.Append(
"]");
context.Response.Write(sb);
context.Response.End();
}
View Code

3.添加:

 StringBuilder sb = new StringBuilder();
sb.Append(
"[");
string b = context.Request["name"];
string c = context.Request["sex"];
string d = context.Request["birthday"];
string e = context.Request["nation"];
string f = context.Request["class"];
string g = context.Request["score"];
using (StudentsDataClassesDataContext con = new StudentsDataClassesDataContext())
{
Stu s
= new Stu();
s.Name
= b;
s.Sex
= Convert.ToBoolean(c);
s.Birthday
= Convert.ToDateTime(d);
s.NationCode
= e;
s.ClassCode
= f;
s.Score
= Convert.ToInt32(g);
con.Stu.InsertOnSubmit(s);
con.SubmitChanges();
List
ss = con.Stu.ToList();
int a1 = ss.Count;
int cc = 0;
foreach (Stu s1 in ss)
{
cc
++;
if (cc < a1)
{ sb.Append(
"{\"ids\":\"" + s1.Ids + "\",\"name\":\"" + s1.Name + "\",\"sex\":\"" + s1.Sexx + "\",\"birthday\":\"" + s1.Birth + "\",\"nation\":\"" + s1.NName + "\",\"class\":\"" + s1.CName + "\",\"score\":\"" + s1.Score + "\"},"); }
if (cc == a1)
{ sb.Append(
"{\"ids\":\"" + s1.Ids + "\",\"name\":\"" + s1.Name + "\",\"sex\":\"" + s1.Sexx + "\",\"birthday\":\"" + s1.Birth + "\",\"nation\":\"" + s1.NName + "\",\"class\":\"" + s1.CName + "\",\"score\":\"" + s1.Score + "\"}"); }
}
sb.Append(
"]");
context.Response.Write(sb);
context.Response.End();
}
View Code

4.删除:

 StringBuilder sb = new StringBuilder();
sb.Append(
"[");
using (StudentsDataClassesDataContext con = new StudentsDataClassesDataContext())
{
string s1 = context.Request["ids"];
Stu sa
= con.Stu.Where(r => r.Ids.ToString() == s1).FirstOrDefault();
con.Stu.DeleteOnSubmit(sa);
con.SubmitChanges();
List
ss = con.Stu.ToList();
int a = ss.Count;
int cc = 0;
foreach (Stu s in ss)
{
cc
++;
if (cc < a)
{ sb.Append(
"{\"ids\":\"" + s.Ids + "\",\"name\":\"" + s.Name + "\",\"sex\":\"" + s.Sexx + "\",\"birthday\":\"" + s.Birth + "\",\"nation\":\"" + s.NName + "\",\"class\":\"" + s.CName + "\",\"score\":\"" + s.Score + "\"},"); }
if (cc == a)
{ sb.Append(
"{\"ids\":\"" + s.Ids + "\",\"name\":\"" + s.Name + "\",\"sex\":\"" + s.Sexx + "\",\"birthday\":\"" + s.Birth + "\",\"nation\":\"" + s.NName + "\",\"class\":\"" + s.CName + "\",\"score\":\"" + s.Score + "\"}"); }
}
}
sb.Append(
"]");
context.Response.Write(sb);
context.Response.End();
View Code

 


推荐阅读
  • Nginx使用(server参数配置)
    本文介绍了Nginx的使用,重点讲解了server参数配置,包括端口号、主机名、根目录等内容。同时,还介绍了Nginx的反向代理功能。 ... [详细]
  • 本文介绍了在mac环境下使用nginx配置nodejs代理服务器的步骤,包括安装nginx、创建目录和文件、配置代理的域名和日志记录等。 ... [详细]
  • Skywalking系列博客1安装单机版 Skywalking的快速安装方法
    本文介绍了如何快速安装单机版的Skywalking,包括下载、环境需求和端口检查等步骤。同时提供了百度盘下载地址和查询端口是否被占用的命令。 ... [详细]
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了C++中省略号类型和参数个数不确定函数参数的使用方法,并提供了一个范例。通过宏定义的方式,可以方便地处理不定参数的情况。文章中给出了具体的代码实现,并对代码进行了解释和说明。这对于需要处理不定参数的情况的程序员来说,是一个很有用的参考资料。 ... [详细]
  • javascript  – 概述在Firefox上无法正常工作
    我试图提出一些自定义大纲,以达到一些Web可访问性建议.但我不能用Firefox制作.这就是它在Chrome上的外观:而那个图标实际上是一个锚点.在Firefox上,它只概述了整个 ... [详细]
  • 本文介绍了Perl的测试框架Test::Base,它是一个数据驱动的测试框架,可以自动进行单元测试,省去手工编写测试程序的麻烦。与Test::More完全兼容,使用方法简单。以plural函数为例,展示了Test::Base的使用方法。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • Python瓦片图下载、合并、绘图、标记的代码示例
    本文提供了Python瓦片图下载、合并、绘图、标记的代码示例,包括下载代码、多线程下载、图像处理等功能。通过参考geoserver,使用PIL、cv2、numpy、gdal、osr等库实现了瓦片图的下载、合并、绘图和标记功能。代码示例详细介绍了各个功能的实现方法,供读者参考使用。 ... [详细]
  • 在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板
    本文介绍了在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板的方法和步骤,包括将ResourceDictionary添加到页面中以及在ResourceDictionary中实现模板的构建。通过本文的阅读,读者可以了解到在Xamarin XAML语言中构建控件模板的具体操作步骤和语法形式。 ... [详细]
author-avatar
回忆寒窗氵之夜_890
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有