随笔分类 - 代码收集
自己感觉不错的代码
摘要:先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript">function lang(key) {mylang = {'ls_input_myb': '请输入您的账户','ls_myb_email': '漫游币账户为邮箱地址','ls_login_password': '请输入您的登录密码','ls_password_length': '密码长度为{0}-{1}位之间','
阅读全文
摘要:static void Main(string[] args) { List<Person> personList =new List<Person>(){ new Person(3),//重复数据 new Person(3), new Person(2), new Person(1) }; //使用匿名方法 List<Person> delegateList = per...
阅读全文
摘要:function HomePage() { if (document.all) { document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(window.location); } else if (window.sidebar) { if (window.netscape) { try { netscape.security.PrivilegeManager.enablePr...
阅读全文
摘要:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FixtableHeader.aspx.cs" Inherits="Text.FixtableHeader" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&q
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Text{ public partial class InsusDate : System.Web.UI.UserControl { private int? _year; private int? _month; private int? _day; ...
阅读全文
摘要:publicvoidDisAbleDropDownListItem(DropDownListddl){foreach(ListItemliinddl.Items){if(li.Value=="1"||li.Text=="RUN"){li.Attributes.Add("disabled","disabled");}}}protected void Page_Load(object sender, EventArgs e) { DisAbleDropDownListItem(ddl); }在Page_Load时,应用
阅读全文
摘要:System.Drawing.Image img = System.Drawing.Image.FromFile(Commen.CommenFunction.Path + picPath);//找到物理地址 pic.Width = img.Width; pic.Height = img.Height;
阅读全文
摘要:public static string divClass = "<div class='viciao'>"; public static string spanClass = "<span class='disabled'>"; /// <summary> /// 分页 /// </summary> /// <param name="png">当前页码</param> /// <param name="sumNum
阅读全文
摘要://权限的验证public class CheckRoleAttribute : ActionFilterAttribute, IActionFilter { public override void OnActionExecuting(ActionExecutingContext filterContext) { try { SougeUser su = filterContext.HttpContext.Session["SystemUser"] as SougeUser; if (su == null) { filterContext.Result = new Red
阅读全文
摘要://jquery.cookie.jsjQuery.webpages = function(obj) { var text; var list = obj.attributes; try { if (list["type"] != undefined) { var type = list["type"].value; switch (type) { case "login": var msg; var url = w...
阅读全文
摘要:///id要找的父类的id///把找到的子类的id存放到idList中 private void GetAllSonPlateId(Guid id, ref List<Guid> idList) { try { List<Guid> gets = _videoR.GetSonId(id); if (gets.Count > 0) { foreach (Guid item in gets) ...
阅读全文
摘要:Baidu 默认的是gb2312 ,google 默认utf-8//oStr 是UrlEncode编码字符串Encoding gb2312 =Encoding.GetEncoding(“gb2312”);Encoding utf-8=Encoding.UTF8;//首先进行utf-8 进行 解码String key =HttpUtility.UrlDecode(oStr,utf8);//将解码的字符再次进行解码String encode=HttpUtility.UrlEncode(key,utf8).ToLower();//与原来编码进行对比,如果不一致,说明编码不正确,用gb2312进行解码
阅读全文
摘要:静态页面包括纯静态和伪静态//替换模版中的内容public bool WriteFile(string strText,string strContent,string strAuthor) { string path = HttpContext.Current.Server.MapPath( "/TesConvert/news/ ");//定义html文件存放路径 Encoding code = Encoding.GetEncoding( "gb2312 ");//定义文字编码 // 读取模板文件 string temp = HttpContext.C
阅读全文
摘要:public static string GetHtmlText(string html) { try { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); return doc.DocumentNode.InnerText; } catch { return null; } }使用第三方控件HtmlAgilityPack
阅读全文
摘要:在 Commen命名空间下 PageCovert类中的静态方法public static bool WriteFile(Article article, string naviget) { string path = HttpContext.Current.Server.MapPath("/news/ ");//定义html文件存放路径 Encoding code = Encoding.GetEncoding("utf-8");//定义文字编码 这里要看静态模版的编码 // 读取模板文件 string tempPath = HttpContext.Cur
阅读全文
摘要:当使用<input type="file" value="" name="upfile" />上传文件时,在后台Request.Files.count==0查看file所在的Form表单的属性 enctype = "multipart/form-data"
阅读全文
摘要:int count = 4;//视频用4byte byte[] byteTemp = new byte[count]; int readCn = stream.Read(byteTemp, 0, 4); for (int i = 0; i < readCn; i++) { s += byteTemp[i].ToString(); } if (type == 1) { //flv mpg rmvb wmv avi 3gp 视频的判断 if (s == "00028" || s == "001186" || s == "46827770&qu
阅读全文
摘要:潇湘的博客图片上传图片缩略图给图片加水印Top1.上传图片:其中FileUpload控件不支持多选。当上传图片或者视频时,要设置web.config中<system.web><httpRuntime maxRequestLength="2097150"/>上传的视频 的大小限制</system.web>string webFilePath = Server.MapPath("ImgUpload/" + fileName);FileUpload.SaveAs(webFilePath);//保存到服务器上2.生成缩略图 /
阅读全文

浙公网安备 33010602011771号