ASP.NET获取隐藏文件的类名
ASP.NET获取隐藏文件的类名(原) http://www.cnblogs.com/lin614/archive/2008/01/25/1052676.html 这个问题在开发中遇到。
this.GetType(). 得到的: ASP.****_ASPX
那我该如何才能得到 类名:****。通过字符串处理得到的类名总感觉不是正规途径。
经过查询资料,再仔细考虑一下asp.net的代码隐藏机制,就不难理解了。
代码隐藏将程序逻辑和静态页面布局分开。这种技术要求创建一个中间基类,它位于积累Page和计算机根据.asp文件生成的类之间。
每个代码隐藏文件都包含了一个部分类,asp.net2.0 还要自己生成一个部分类。然后,一起编译成一个类,成为.aspx文件生成的类的基类。这么一来。
很明显this访问到的是.aspx页面编译生成的类,那如果我们依靠得到代码隐藏文件的类名,自然就要访问它的基类了。
因此。this.GetType().BaseType.Name,就是想要的结果了。 应用示例:在客户的后台管理页面上,没有登录跳至登录页,已登录但未完善基础资料,不能进入其他设置管理页面。 UserAdminPageBase.cs (基类页面) protected void override OnInit(EventArgs e)
{
base.OnInit(e);
//登录检查
if(Session[“xxx”]==null)
Response.Redirect(“login.aspx?Return=xxx”);
//资料完善检查
User u=(User)Session[“xxx”];
if(User.Data==null)
if(!this.GetType().BaseType.Equals(typeof(UserDataInit))) //避免死循环,”UserDataInit”是页面”UserDataInit.aspx”的后台类
Response.Redirect(“UserDataInit.aspx”);
}
相关文档:
This server-based method is documented in the Visual Studio help files. Open the Help Index, and enter PrintToPrinter in the "Look for:" box. The syntax for this method is:
Report.PrintToPrinter(<copies as int>, <collated as True/False>, <startpage as int>, <endp ......
ASP.NET Excel导入到SQL Server数据库
提供把Excel里的数据导入到SQL Server 数据库,前提是Excel里的字段在Sql Server表里都有,不然会出现错误。注释很详细哦!要引用的命名空间是:
using System.Data.OleDb;
using System.Data.SqlClient;
//操作类
public class ExcelToSQL
{
& ......
ASP.NET Excel导出(动态生成)解决方案
(一)、服务器端的excel组件来生成目标Excel
即在后台调用excel组件,来读取模板,填写模板的。就是后台启动Excel来处理的,在进程管理器里可以查看到它的进程。
优点:Excel处理功能丰富,多样,可以完成一切的Excel文件处理。
缺点:服务器端要装Excel ......
作者: 王景 来源: 博客园 发布时间: 2010-03-08 14:18 阅读: 239 次 原文链接 [收藏]
最近在招聘新的团队成员中,自己想出了一些问题。先列出来,有机会不断更新吧。
第一部分:
互相介绍及了解
1.请介绍一下你 ......
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient; ......