asp.net显示用户信息
web.config
<?xml version="1.0" encoding="utf-8"?> <!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
--> <configuration> <system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<connectionStrings>
<add connectionString="Data Source = .; Initial Catalog = mysql; Integrated Security = True;" name="conStr" /> </connectionStrings>
</configuration>
UserInfo.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>
<link href="tableStyle.css" rel="stylesheet" />
</head>
<body>
<table>
<tr>
<th>id</th>
<th>姓名</th>
<th>邮箱</th>
<th>地址</th>
</tr>
$tbody
</table>
</body>
</html>
UserInfo.ashx
<%@ WebHandler Language="C#" Class="UserInfo" %> using System;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Text; public class UserInfo : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
context.Response.Write("Hello World");
//连接字符串
string str = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString; using (SqlConnection con = new SqlConnection(str))
{
//获取数据库表格
using (SqlDataAdapter sda = new SqlDataAdapter("select * from student", con))
{
//定义表格dt
DataTable dt = new DataTable();
//将数据库的表格存入dt
sda.Fill(dt);
//定义sb来循环接收字符串
StringBuilder sb = new StringBuilder();
for (int i = ; i < dt.Rows.Count; i++)
{
//遍历表格dt,将每行数据作为字符串存入sb
sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><tr>",
dt.Rows[i]["id"].ToString(), dt.Rows[i]["name"].ToString(), dt.Rows[i]["email"].ToString(), dt.Rows[i]["address"].ToString());
}
//获取html路径
string path = context.Request.MapPath("UserInfo.html");
//获取html内容
string contentHtml = File.ReadAllText(path);
//把占位符部分替换
contentHtml = contentHtml.Replace("$tbody", sb.ToString());
//输出网页
context.Response.Write(contentHtml);
} }
} public bool IsReusable
{
get
{
return false;
}
} }
表格css样式
caption
{
padding: 5px ;
width: 700px;
font: italic 11px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
text-align: right;
} th
{
font: bold 11px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
color: #burlywood;
border-right: 1px solid #C1DAD7;
border-left: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
border-top: 1px solid #C1DAD7;
letter-spacing: 2px;
text-transform: uppercase;
text-align: left;
padding: 6px 6px 6px 12px;
background: #0066AA no-repeat;
} th.nobg
{
border-top: ;
border-left: ;
border-right: 1px solid #C1DAD7;
background: none;
} td
{
border-left: 1px solid #C1DAD7;
border-right: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
background: #fff;
font-size: 11px;
padding: 6px 6px 6px 12px;
color: #4f6b72;
} td.alt
{
background: #F5FAFA;
color: #;
} th.spec
{
border-left: 1px solid #C1DAD7;
border-top: ;
background: #fff no-repeat;
font: bold 10px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
} th.specalt
{
border-left: 1px solid #C1DAD7;
border-top: ;
background: #f5fafa no-repeat;
font: bold 10px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
color: #;
} .span_link
{
cursor:pointer;
color:Black;
} .tr_Category
{
} .pageLink
{
color:Blue;
margin-left:2px;
margin-right:2px;
} .tr_Category_P td
{
background-color:#EEEEFF;
}
asp.net显示用户信息的更多相关文章
- finger---用于查找并显示用户信息
finger finger命令用于查找并显示用户信息.包括本地与远端主机的用户皆可,帐号名称没有大小写的差别.单独执行finger指令,它会显示本地主机现在所有的用户的登陆信息,包括帐号名称,真实姓名 ...
- ajax文本空输入显示用户信息
一般文件代码 public void ProcessRequest (HttpContext context) { //获取主见值 string s = context.Request["u ...
- struts2使用拦截器完成登陆显示用户信息操作和Struts2的国际化
其实学习框架,就是为了可以很好的很快的完成我们的需求,而学习struts2只是为了替代之前用的servlet这一层,框架使开发更加简单,所以作为一个小菜鸟,特别感谢那些超级无敌变态开发的框架供我们使用 ...
- Jquery 类似新浪微博,鼠标移到头像,用浮动窗口显示用户信息,已做成一个jquery插件
请注意!!!!! 该插件demo PHP 的 demo下载 C#.NET的demo下载 需要如下图, 1.鼠标移动到头像DIV时,Ajax获取数据,并让浮动DIV显示出来. 2.鼠标可以移动到上面浮 ...
- 门户系统整合sso cookie共享及显示用户信息
1.1 门户系统整合sso 在门户系统点击登录连接跳转到登录页面.登录成功后,跳转到门户系统的首页,在门户系统中需要从cookie中 把token取出来.所以必须在登录成功后把token写入cooki ...
- JSP中显示用户信息
<%@ page language= "java" contentType="text/html;charset=UTF-8" %><%@ p ...
- wordpress教程之the_author_meta()显示用户的信息
描述 模板标签函数the_author_meta可以显示用户数据.如果该函数在文章主循环(Loop)中,则不必指定作者的ID值,标签所显示的就是当前文章作者的内容.如果在主循环(Loop)外,则需要指 ...
- .NET 实现自定义ContextUser的Identity和Principal实现自定义用户信息,权限验证。
备用收藏,http://blog.csdn.net/msdnxgh/article/details/6894885 .NET 实现自定义ContextUser的Identity和Principal 在 ...
- 基于jsp+servlet图书管理系统之后台用户信息查询操作
上一篇的博客写的是插入操作,且附有源码和数据库,这篇博客写的是查询操作,附有从头至尾写的代码(详细的注释)和数据库! 此次查询操作的源码和数据库:http://download.csdn.net/de ...
随机推荐
- jQuery ajax - ajax() 方法详解
一些代码通过jQuery来做ajax异步提交. //验证昵称是否存在 function checkNickNameIsExist(){ var nickName = jQuery("#nic ...
- FZU - 2039 Pets (二分图匹配 2011年全国大学生程序设计邀请赛(福州))
Description Are you interested in pets? There is a very famous pets shop in the center of the ACM ci ...
- [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路
来源于:http://www.jianshu.com/p/5124eef40bf0 [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路 手把手教你整合最优雅SSM框架:S ...
- 从gentoo回归Arch,上组图
Arch一直在我笔记本里边,只是玩gentoo时我不进Arch了,现在回归Arch,升级到了最新,用上了gentoo的最新的2.6.31内核(自己配置,无initrd),引导程序用的grub4dos: ...
- 【LeetCode】31. Next Permutation (2 solutions)
Next Permutation Implement next permutation, which rearranges numbers into the lexicographically nex ...
- XP系统下建立WIFI热点让手机、电脑能上网
http://wenku.baidu.com/view/372c5b1fa300a6c30c229f42.html 这里记录xp系统下建立共享无线网络连接,若是支持手机设备上的话,网络适配器必须是wi ...
- http://www.cnblogs.com/txw1958/p/alipay-f2fpay.html
一.条码支付及二维码支付介绍 1. 条码支付 条码支付是支付宝给到线下传统行业的一种收款方式.商家使用扫码枪等条码识别设备扫描用户支付宝钱包上的条码/二维码,完成收款.用户仅需出示付款码,所有收款操作 ...
- 【js】js中的||和&&
逻辑与&&和逻辑或||操作符可以应用于任何类型的操作数,而不仅仅是布尔值. 几乎所有语言中||和&&都遵循“短路”原理, 如&&中第一个表达式为假就不会 ...
- SAP接口设计的扩展性考虑
由于现在的系统和SAP的接口出现了几次变更,因此需要对系统进行设计改造.由于系统中和SAP交互的接口不止一处,而且也是在不同的时间段进行开发,并由不同的人员来完成的,因此我在维护升级的 ...
- selenium python学习笔记---添加等待时间
http://selenium-python.readthedocs.io/waits.html 有时候为了保证脚步运行的稳定性,需要在脚本中添加等待时间 添加休眠:需要引入time包,选择一个固定的 ...