App_code内Common类通用方法调用
2014-09-19 14:26
218 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///Common 的摘要说明
/// </summary>
public class Common
{
private volatile static Common _instance = null;
private static readonly object lockHelper = new object();
private static readonly object lockInit = new object();
public static Common Instance
{
get
{
if (_instance == null)
{
lock (lockHelper)
{
if (_instance == null)
{
_instance = new Common();
}
}
}
return _instance;
}
}
//根据id取管理员
public string GetAdminName(object id)
{
if (admin_userInstance.Instance.GetModelById(int.Parse(id.ToString())) != null)
{
return admin_userInstance.Instance.GetModelById(int.Parse(id.ToString())).UserName;
}
return "无";
}
}
前台调用:
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Common.Instance.GetAdminName(Eval("AdminUserId")) %>'></asp:Label>
</ItemTemplate>
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///Common 的摘要说明
/// </summary>
public class Common
{
private volatile static Common _instance = null;
private static readonly object lockHelper = new object();
private static readonly object lockInit = new object();
public static Common Instance
{
get
{
if (_instance == null)
{
lock (lockHelper)
{
if (_instance == null)
{
_instance = new Common();
}
}
}
return _instance;
}
}
//根据id取管理员
public string GetAdminName(object id)
{
if (admin_userInstance.Instance.GetModelById(int.Parse(id.ToString())) != null)
{
return admin_userInstance.Instance.GetModelById(int.Parse(id.ToString())).UserName;
}
return "无";
}
}
前台调用:
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Common.Instance.GetAdminName(Eval("AdminUserId")) %>'></asp:Label>
</ItemTemplate>
相关文章推荐
- 创建的web窗体中,添加的app_code文件夹不能调用的解决方法
- 使用API调用Winodws各种通用对话框(Common Diaglog)的方法
- VS2012App_Code目录里类文件无法被调用的解决方法
- VC调用存储过程的通用方法(ORACLE篇)
- SqlServer通用分页的调用方法
- VC调用存储过程的通用方法(ORACLE篇)
- 写了一个通用的用户选择页面,记录一下调用方法
- 反射APP_CODE下的类和方法
- VC调用存储过程的通用方法(ORACLE篇)
- 寫了個通用的比較器(comparer),應用动态生成Lambda(调用属性及方法)
- VC调用存储过程的通用方法(SQLServer篇)
- (2010-10-07)VS2008 引用App_Code下的类文件问题解决方法
- 如何在Web App Project 或者 Web Site Project的App_Code 内使用 Profile/ProfileCommon
- VC调用存储过程的通用方法(SQLServer篇)
- IE6下Ms Ajax Lib 调用Ajaxtoolkit时Common_InvalidPaddingUnit未定义的解决方法
- VC调用存储过程的通用方法(SQLServer篇)
- VC调用存储过程的通用方法(ORACLE篇)
- IE6下Ms Ajax Lib 调用Ajaxtoolkit时Common_InvalidPaddingUnit未定义的解决方法
- C#调用VC的DLL时AfxGetApp失败的解决方法
- SUN ONE APPSERVER 7 连接池和数据源的配置方法和调用