一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp.net+easyui框架上传图片之前判断图片格式及预览

时间:2015-07-06 编辑:简简单单 来源:一聚教程网

上传图片功能虽然很简单,但是在上传图片之前验证图片的格式,并同时实现预览,还是有很多细节需要注意的,本文的就详细来解说这个。

html页面


 
    选择图片:javascript:setImagePreview(this,localImag,preview);" type="file" />  
 
    预  览:  
 
    <%--预览,默认图片--%>  
    预览图片   
 


js代码


 
<%--easyui 的js--%>  
 
<%--中文js--%>  
 
 
<%--上传图片时js--%>  
 


     上传图片时,需要jquery.form.js的js文件,下载地址:http://plugins.jquery.com/form/

=================================================================================

  最近有网友,总觉得看的还不是太明白,能不能将paintingBLL和paintingEntity代码贴一下-----新人求罩,我个人觉得实体层就没有必要了,下面我就将paintingBLL的源码粘一下,仅供大家参考。

using System;  
using System.Data;  
using System.Collections.Generic;  
using Common;  
using Entity;  
using DALFactory;  
using IDAL;  
namespace BLL  
{  
    ///  
    /// paintingBLL  
    ///
 
    public partial class paintingBLL  
    {  
        private readonly IpaintingDAL dal=DataAccess.CreatepaintingDAL();  
        public paintingBLL()  
        {}  
        #region  BasicMethod  
 
        ///  
        /// 得到最大ID  
        ///
 
        public int GetMaxId()  
        {  
            return dal.GetMaxId();  
        }  
 
        ///  
        /// 是否存在该记录  
        ///
 
        public bool Exists(int PaintingID)  
        {  
            return dal.Exists(PaintingID);  
        }  
 
        ///  
        /// 增加一条数据  
        ///
 
        public bool Add(Entity.paintingEntity Entity)  
        {  
            return dal.Add(Entity);  
        }  
 
        ///  
        /// 更新一条数据  
        ///
 
        public bool Update(Entity.paintingEntity Entity)  
        {  
            return dal.Update(Entity);  
        }  
 
        ///  
        /// 删除一条数据  
        ///
 
        public bool Delete(int PaintingID)  
        {  
              
            return dal.Delete(PaintingID);  
        }  
        ///  
        /// 删除一条数据  
        ///
 
        public bool DeleteList(string PaintingIDlist )  
        {  
            return dal.DeleteList(PaintingIDlist );  
        }  
 
        ///  
        /// 得到一个对象实体  
        ///
 
        public Entity.paintingEntity GetEntity(int PaintingID)  
        {  
              
            return dal.GetEntity(PaintingID);  
        }  
 
        ///  
        /// 得到一个对象实体,从缓存中  
        ///
 
        public Entity.paintingEntity GetEntityByCache(int PaintingID)  
        {  
              
            string CacheKey = "paintingEntityEntity-" + PaintingID;  
            object objEntity = Common.DataCache.GetCache(CacheKey);  
            if (objEntity == null)  
            {  
                try  
                {  
                    objEntity = dal.GetEntity(PaintingID);  
                    if (objEntity != null)  
                    {  
                        int EntityCache = Common.ConfigHelper.GetConfigInt("EntityCache");  
                        Common.DataCache.SetCache(CacheKey, objEntity, DateTime.Now.AddMinutes(EntityCache), TimeSpan.Zero);  
                    }  
                }  
                catch{}  
            }  
            return (Entity.paintingEntity)objEntity;  
        }  
 
        ///  
        /// 获得数据列表  
        ///
 
        public DataSet GetList(string strWhere)  
        {  
            return dal.GetList(strWhere);  
        }  
 
        ///  
        /// 获得数据列表  
        ///
 
        public DataSet GetPaintingList(string strWhere)  
        {  
            return dal.GetPaintingList(strWhere);  
        }  
        ///  
        /// 获得前几行数据  
        ///
 
        public DataSet GetList(int Top,string strWhere,string filedOrder)  
        {  
            return dal.GetList(Top,strWhere,filedOrder);  
        }  
        ///  
        /// 获得数据列表  
        ///
 
        public List GetEntityList(string strWhere)  
        {  
            DataSet ds = dal.GetList(strWhere);  
            return DataTableToList(ds.Tables[0]);  
        }  
        ///  
        /// 获得数据列表  
        ///
 
        public List DataTableToList(DataTable dt)  
        {  
            List EntityList = new List();  
            int rowsCount = dt.Rows.Count;  
            if (rowsCount > 0)  
            {  
                Entity.paintingEntity Entity;  
                for (int n = 0; n < rowsCount; n++)  
                {  
                    Entity = dal.DataRowToEntity(dt.Rows[n]);  
                    if (Entity != null)  
                    {  
                        EntityList.Add(Entity);  
                    }  
                }  
            }  
            return EntityList;  
        }  
 
        ///  
        /// 获得数据列表  
        ///
 
        public DataSet GetAllList()  
        {  
            return GetList("");  
        }  
 
        ///  
        ///checkbox获取数据列表  
        ///
 
        public int GetRecordCount(string strWhere)  
        {  
            return dal.GetRecordCount(strWhere);  
        }  
        ///  
        /// 分页获取数据列表  
        ///
 
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)  
        {  
            return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);  
        }  
        ///  
        /// 分页获取数据列表  
        ///
 
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)  
        //{  
            //return dal.GetList(PageSize,PageIndex,strWhere);  
        //}  
 
        #endregion  BasicMethod  
        #region  ExtensionMethod  
 
        #endregion  ExtensionMethod  
    }  
}  


分页

热门栏目