ASP.NET中将对界面的操作封装到DLL中
来源:互联网 发布:star rating.js 编辑:程序博客网 时间:2024/05/16 04:35
ASP.NET中将对界面的操作封装到DLL中
单位有一个ASP.NET Web Application项目,以该项目为例,简单研究了一下项目模块化和界面逻辑完全独立等。
定义:
界面,ASPX文件中的纯HTML代码;
资源,存放在XML或其他格式文件中文本信息,供界面显示;
界面驱动,多语言资源显示、界面显示控制等;
逻辑,相关业务代码
具体实现
1、DLL的引用中添加System.Web
2、每个ASPX在DLL中都对应一个CS类文件
3、每个类中都引用
using System.Web;
using System.Web.UI;
如果需要操作页面控件,还需要引用:
using System.Web.UI.Control;
4、定义一个基类:
using System.Web;
using System.Web.UI;
public class Base
{
private Page page = null;
public Base()
{
}
protected void Initialize(Page _page)
{
if (_page != null)
{
page = _page;
}
}
protected Label FindLabel(string name)
{
if (name.Length > 0)
{
return (Label)FindControl(name);
}
else
{
return null;
}
}
private Control FindControl(string name)
{
if (name.Length > 0)
{
return page.FindControl(name);
}
else
{
return null;
}
}
};
5、每个界面驱动类都继承基类
using System.Web;
using System.Web.UI;
using System.Web.UI.Control;
public class LoginUI : Base
{
public LoginUI(Page _page)
{
base.Initialize(_page);
}
public void LoadResource()
{
Label lblUser = FindLabel("lblUser");
lblUser.Text = "Username: ";
...
//绑定事件
Label lblTips = FindLabel("lblTips");
lblTips.click += new EventHandler( this.lblTips_Click);
}
public void lblTips_Click( object sender, EventArgs e)
{
...
}
};
- ASP.NET中将对界面的操作封装到DLL中
- ASP.NET中对cookie的操作
- ASP.NET 封装JS文件到DLL中并在页面中调用
- ASP.NET 中 DataGrid 导出到 Excel 的封装实现
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- SQL Server 2005新特性之使用with关键字解决递归父子关系(详细)
- BIOS入口地址:FFFF:0000是指什么意思?在物理上是指内存条的什么位置?
- 最短路
- MFC下CSocket编程详解
- php5总结
- ASP.NET中将对界面的操作封装到DLL中
- SQL连接
- UML的基本构造块
- Core Architecture Blocks (核心架构模块)(二)
- 最短路
- ANDROID开发与手机USB调试--手机调试模式出不来
- 可重入内核
- 稀疏矩阵的快速转制
- 求分割的数目