作者: wushijun5200

layui-模板- if for 知识点

<script type=”text/html” template> {{# if(xxxx){ }} {{# } else if(xxxxx) { }} {{# } else { }} {{# } }} </script> <!– 是否显示 –> <script type=”text/html” id=”isShow”> {{# if(d.gradeId === ‘2’){ }} 机构 {{# } }} {{# if(d.gradeId === ‘2’){ }} 机构 {{# } else { }} 机构 {{# } }} </script> ——————— {{# if(d.gradeId==2){ }} <div class=”layui-form-item”> <label class=”layui-form-label”>数量</label> </div> {{# } else if(d.gradeId==25) { }} <div class=”layui-form-item”> <label class=”layui-form-label”>logo</label> </div> {{# } else { }} {{# } }}  

继续阅读

ASP.NET MVC 5使用X.PagedList.Mvc进行分页教程

3、\Controllers\UserController.cs 后台代码基本用法: using PagedList; // GET: User/1 public ActionResult Index(int page = 1) { const int pageSize = 10; //List<User> users = (from u in db.Users // orderby u.Id descending // select u).Skip((page – 1) * pageSize).Take(pageSize).ToList(); //return View(users); var iUsers = db.Users.OrderBy(p => p.Id).ToPagedList(page, pageSize); return View(iUsers); } 4、\Views\User\Index.cshtml 前台代码基本用法: @using PagedList @using PagedList.Mvc <table class=“table”> xxxx xxxx xxxx </table> @Html.PagedListPager((IPagedList)Model, page => Url.Action(“Index”, new { page })) 5、\App_Start\RouteConfig.cs 配置一下: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.Map

继续阅读

在 ASP.NET MVC 中应用 KindEditor

//文件保存目录路径 const string SavePath = “/uploadfile/”; #region uploadJson // // GET: /KindEditorHandler/Upload public ActionResult Upload() { ////文件保存目录路径 //const string savePath = “/Content/Uploads/”; //文件保存目录URL var saveUrl = SavePath; //定义允许上传的文件扩展名 var extTable = new Hashtable { {“image”, “gif,jpg,jpeg,png,bmp”}, {“flash”, “swf,flv”}, { “media”, “swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb”}, { “file”, “doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2”} }; //最大文件大小 const int maxSize = 2000000; var imgFile = Request.Files[“imgFile”]; if (imgFile == null) { return ShowError(“请选择文件。”); } var dirPath = Server.MapPath(SavePath); if (!Directory.Exists(dirPath)) { //return ShowError(“上传目录不存在。” + dirPath); Directory.CreateDirectory(dirPath); } var dirName = Request.QueryString[“dir”]; if (Str

继续阅读

https://www.cnblogs.com/yq-Hua/p/5540846.html

开启KindEditor代码高亮功能 开启KindEditor代码高亮功能 KindEditor4.0 开始支持插入代码功能!!!如何使用插入代码功能实现前段页面代码高亮显示和后台代码维护显示!!! 1. 需要高亮显示代码的前台页面需要引用相应的css样式和js文件 <link href=”../../editor/plugins/code/prettify.css” rel=”stylesheet” /> <script type=”text/javascript” src=”../../editor/plugins/code/prettify.js”></script> 2. 插入脚本 <script type=”text/javascript”> $(function () { prettyPrint(); }); </script> 这样前台页面就可实现类似这样效果的代码显示了! 之后,还可以根据自己的喜好,对现有前台样式进行调整,比如我的前台样式会引发横向滚动条显示不出来,这样就导致超长行的代码显示不全的问题。 我修改了对应的prettify.css 文件,将该文件里的pre.prettyprint 样式追究了一个overflow:auto 即可….   but,后台编辑器维护里面还没有插件样式,这样就导致编辑器中插入的代码跟普通文字一样,无法区分开!所以可使用如下方式对后台编辑器里的显示进行调整。 var editor = KindEditor.create(‘textarea.editor’, { cssPath : [‘[kePath]/plugins/code/prettify.css’] }); 这样后台编辑器就可以实现如下所显示的效果了:

继续阅读

在线HTML编辑器Kindeditor-4.1.10简易示例

第一步,先在需要调用编辑器的表单中添加文本域textarea,作为KindEditor实现的载体,示例代码如下: <textareaid=”editor_id”name=”content”style=”width:700px;height:300px;”>   默认显示的内容  </textarea> 第二步,引入KindEditor的js文件。由于KindEditor是用JS编写的,因此在初始化编辑器之前,必须引入KindEditor的js文件,引入方法示例代码如下 <script charset=”utf-8″ src=”/你的目录/kindeditor.js”></script> <script charset=”utf-8″ src=”/你的目录/lang/zh_CN.js”></script> 第三步,初始化KindEditor编辑器,初始化示例如下: <script>  KindEditor.ready(function(K) { window.editor = K.create(‘#editor_id’); }); </script> Note:id在当前页面必须是唯一的值。 第四步,获取KindEditor中的HTML数据。KindEditor的可视化操作在新创建的iframe上执行,代码模式下的textarea框也是新创建的,所以最后提交前需要执行 sync() 将HTML数据设置到原来的textarea。示例代码如下: <script>   // 取得HTML内容   html = editor.html();   // 同步textarea[“#editor_id”]和KindEditor数据后,可以直接取得textarea的value,否则te

继续阅读

ZipHelper

public class ZipHelper { public static void ZipFile(string strFile, string strZip) { if (strFile[strFile.Length – 1] != Path.DirectorySeparatorChar) strFile += Path.DirectorySeparatorChar; ZipOutputStream s = new ZipOutputStream(File.Create(strZip)); s.SetLevel(6); zip(strFile, s, strFile); s.Finish(); s.Close(); } private static void zip(string strFile, ZipOutputStream s, string staticFile) { if (strFile[strFile.Length – 1] != Path.DirectorySeparatorChar) strFile += Path.DirectorySeparatorChar; Crc32 crc = new Crc32(); string[] filenames = Directory.GetFileSystemEntries(strFile); foreach (string file in filenames) { if (Directory.Exists(file)) { zip(file, s, staticFile); } else // 否则直接压缩文件 { //打开压缩文件 FileStream fs = File.OpenRead(file); byte[] buffer = new byte[fs.Length]; fs.Read(buffer,

继续阅读

FTPHelper

1 public class FTPHelper 2 { 3 #region 字段 4 /// <summary> 5 /// ftp地址,带ftp协议 6 /// </summary> 7 private string strFtpURI; 8 /// <summary> 9 /// ftp用户名 10 /// </summary> 11 private string strFtpUserID; 12 /// <summary> 13 /// ftp的ip地址 14 /// </summary> 15 private string strFtpServerIP; 16 /// <summary> 17 /// ftp用户登录密码 18 /// </summary> 19 private string strFtpPassword; 20 /// <summary> 21 /// ftp目录路径 22 /// </summary> 23 private string strFtpRemotePath; 24 #endregion 25 26 /// <summary> 27 /// 连接FTP服务器 28 /// </summary> 29 /// <param name=”strFtpServerIP”>FTP连接地址</param> 30 /// <param name=”strFtpRemotePath”>指定FTP连接成功后的当前目录, 如果不指定即默认为根目录</param> 31 /// <param name=”strFtpUserID”>用户名</pa

继续阅读

ExcelHelper

1 public class ExcelHelper 2 { 3 /// <summary> 4 /// 将Excel文件中的数据读出到DataTable中 5 /// </summary> 6 /// <param name=”strFile”>文件路径</param> 7 /// <returns>datatable</returns> 8 public static DataTable Excel2DataTable(string strFile, string strSheetName, string strTableName) 9 { 10 DataTable dt = new DataTable(); 11 IWorkbook workbook = null; 12 using (FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.Read)) 13 { 14 //office2003 HSSFWorkbook 15 //office2007 XSSFWorkbook初始化 16 workbook = new XSSFWorkbook(fs); 17 } 18 ISheet sheet = workbook.GetSheet(strSheetName); 19 // 20 dt = Export2DataTable(sheet, 0, false); 21 return dt; 22 23 } 24 /// <summary> 25 /// 将指定sheet中的数据导入到datatable中 26 /// </summary> 27 /// <param name=”sheet”&g

继续阅读