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 ...
随机推荐
- 实践:由0到1-无线大数据UX团队的成长
背景 大数据产品的在项目成立之初,采用的是模仿原有网优工具的方式做UI设计,由BA主导画草图.手绘线框图.excel制作,更有直接打开参考产品做原型的方式,没有统一的设计和规范可言.随着团队逐渐增多. ...
- Foundations of Machine Learning: Rademacher complexity and VC-Dimension(1)
Foundations of Machine Learning: Rademacher complexity and VC-Dimension(1) 前面两篇文章中,我们在给出PAC-learnabl ...
- Java优化技巧
过早的优化是万恶之源. 优化了的代码可读性变差,可改性可适应性变差,可维护性变差. 远离过度优化,优化是个无底洞,把主要精力放在代码逻辑上. 优化的代码是活在当下的,是严重依赖硬件的,不利于表达永恒的 ...
- iOS10 推送必看 UNNotificationContentExtension
来源:徐不同(@2016徐小爷) 链接:http://www.jianshu.com/p/45933f5450a4 大伙久等啦~这绝对是最全最详细的 UNNotificationContentExte ...
- SDL 2.0 API by Category
Basics View information and functions related to... View the header Initialization and Shutdown SDL. ...
- 《JAVA与模式》之适配器模式(转载)
适配器模式比较简单,偷个懒,直接转载一篇. 个人理解: * 类适配器是通过继承来完成适配 * 对象适配器是通过传递对象来完成适配 * 不管哪种,其实都是通过引用特殊接口的对象来完成特殊接口的适配调用 ...
- 在Debug模式下中断, 在Release模式下跳出当前函数的断言
在Debug模式下中断, 在Release模式下跳出当前函数的断言 #ifdef DEBUG #define __breakPoint_on_debug asm("int3") # ...
- java实现简单webserver(分析+源码)
在日常的开发中,我们用过非常多开源的webserver,比如tomcat.apache等等.如今我们自己实现一个简单的webserver,主要的功能就是用户点击要訪问的资源,server将资源发送到c ...
- 解决windows server2012 评估版本过期,系统会自动关机
解决windows server2012 评估版本过期,系统在1小时后会自动关机. 重置方法:以管理员方式运行命令行,执行slmgr.vbs /rearm,可以使授权延长180天,但是仅能延长5次.
- mysql InnoDB 的行锁
表的引擎类型必须为InnoDB才可以进行此操作. 相关链接:http://www.cnblogs.com/CyLee/p/5579672.html 共享锁:单独运行前两句,然后新建一个会话使用第三句. ...