随笔分类 -  ASP.NET

摘要:DataView dv = new DataView(table); dv.RowFilter = " Type='10' and Visible='true'"; dv.Sort = "DisplaySequence ASC"; DataTable dt_New = dv.ToTable(); ... 阅读全文
posted @ 2014-11-13 14:08 yellowshorts 阅读(133) 评论(0) 推荐(0)
摘要:http[\:]//[^"]+ 阅读全文
posted @ 2014-04-28 16:35 yellowshorts 阅读(191) 评论(0) 推荐(0)
摘要:1.前台代码2.后台代码 protected void btnImprot_Click(object sender, EventArgs e) { String fileName = System.IO.Path.GetFileName(fupFiles.FileName); String path = Server.MapPath("~/" + fileName); fupFiles.SaveAs(path); DataTable dt = ImportExcelByDB(path); } public... 阅读全文
posted @ 2014-03-13 13:22 yellowshorts 阅读(1849) 评论(0) 推荐(0)
摘要:1.部分类的使用 关键字partialpublic partial class TcCard{} 在使用三层架构开发项目 我们都会使用工具生成 Model层,工具生成的Model有时候不能满足我们的特殊需求 因而我们会修改Model新增一些 自己的内容 为了不和工具生成代码 每次覆盖掉我们自己更改的内容 因为我们使用部分类 来实现如图 TcCard与TcCard2属于同一个类 我们可以在两个类的文件中 对它进行编辑 而不更改工具生成的Model内容 阅读全文
posted @ 2014-02-27 10:53 yellowshorts 阅读(255) 评论(0) 推荐(0)
摘要:var p = DataTable.AsEnumerable().Where(t => t.Field("ChannelID") == int.Parse(code)).Select(d => d); if (p != null && p.Count() > 0) { return p.Select(c => c.Field("name")).First(); } else { return ""; } 阅读全文
posted @ 2014-02-24 14:52 yellowshorts 阅读(9440) 评论(0) 推荐(1)
摘要:首先新建一个类,继承自System.Web.UI.Page,然后重写OnInit,如下:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;namespaceFuSession{pu 阅读全文
posted @ 2014-01-15 15:43 yellowshorts 阅读(301) 评论(0) 推荐(0)
摘要:1 constintGB=1024*1024*1024;//定义GB的计算常量2constintMB=1024*1024;//定义MB的计算常量3constintKB=1024;//定义KB的计算常量4publicstringByteConversionGBMBKB(Int64KSize)5{6if(KSize/GB>=1)//如果当前Byte的值大于等于1GB7return(Math.Round(KSize/(float)GB,2)).ToString()+"GB";//将其转换成GB8elseif(KSize/MB>=1)//如果当前Byte的值大于等于1M 阅读全文
posted @ 2013-05-18 15:35 yellowshorts 阅读(15552) 评论(0) 推荐(0)
摘要:水仙花数的算法是一个三位数每一位数的立方相加等于该数本身1protectedvoidButton1_Click(objectsender,EventArgse) 2 {3inta=0,b=0,c=0;//定义变量4ListBox1.Items.Clear();//清空ListBox1控件5for(inti=100;i<=1000;i++)//遍历所有3位数6{7a=i/100;//获取3位数中的第一个数8Math.DivRem(i,100,outb);//获取3位数中的后两位数9b=b/10;//获取3位数中的第二位数10Math.DivRem(i,10,outc);//获取3位数中的第 阅读全文
posted @ 2013-05-18 15:33 yellowshorts 阅读(4659) 评论(0) 推荐(0)
摘要:1protectedvoidButton1_Click(objectsender,EventArgse)2{3ListBox1.Items.Clear();//清空ListBox控件4intp=0,n=0,a=1,b=1;//定义变量5try6{7p=Convert.ToInt32(TextBox1.Text);//将字符型转换成数值型8}9catch//出现错误10{11Response.Write("<script>alert('请输入数值型数据');</script>");12TextBox1.Text="15&quo 阅读全文
posted @ 2013-05-18 15:28 yellowshorts 阅读(1788) 评论(0) 推荐(0)
摘要:1if(TextBox1.Text.Length>8)2{3TextBox1.Text=TextBox1.Text.Substring(0,8);4}5else6{7intj=8-TextBox1.Text.Length;8for(inti=0;i<j;i++)9{10TextBox1.Text="0"+TextBox1.Text;11}12} 阅读全文
posted @ 2013-05-18 15:14 yellowshorts 阅读(311) 评论(0) 推荐(0)
摘要:1.aspx页面1<div>2<table>3<tr>4<td>5<asp:LabelID="Label1"runat="server"Text="字符串"Font-Size="10pt"></asp:Label>6</td>7<td>8<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>9</t 阅读全文
posted @ 2013-05-18 15:10 yellowshorts 阅读(217) 评论(0) 推荐(0)
摘要:for(int i=0:i<ds.Table[0].Rows.Count:i++){ Label tb=Page.Master.FindControl("").FindControl("Lable"+(i+1)) as Lable;tb.Text=ds.Table[0].Rows[i]["title"].Tostring();} 阅读全文
posted @ 2013-03-27 10:12 yellowshorts 阅读(1254) 评论(0) 推荐(0)
摘要:写在C# cs 界面页面图片切换效果http://www.lanrentuku.com/js/jiaodiantu-927.html1StringBuildersb=newStringBuilder();2sb.Append("<scripttype=\"text/javascript\">");3sb.Append("linkarr=newArray();");4sb.Append("picarr=newArray();");5sb.Append("textarr=newArray();&q 阅读全文
posted @ 2013-03-26 17:49 yellowshorts 阅读(761) 评论(0) 推荐(0)
摘要:以下转自http://hi.baidu.com/anyedage/blog/item/e8c45ed3b90d25023af3cf26.htmlRequest.ApplicationPath: /testwebRequest.CurrentExecutionFilePath: /testweb/default.aspxRequest.FilePath: /testweb/default.aspxRequest.Path: /testweb/default.aspxRequest.PathInfo:Request.PhysicalApplicationPath: E:\WWW\testweb\R 阅读全文
posted @ 2013-03-12 11:21 yellowshorts 阅读(575) 评论(0) 推荐(0)
摘要:public static string NoHTML(string Htmlstring) { if (Htmlstring.Length > 0) { //删除脚本 Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); //删除HTML Htmlstring = Regex.Re... 阅读全文
posted @ 2013-03-09 13:50 yellowshorts 阅读(1958) 评论(0) 推荐(0)
摘要:索引器允许类或者结构的实例按照与数组相同的方式进行索引。索引器类似属性,但不同之处在于它们的访问器采用参数。它可以像数组那样对对象采用下标。它提供了通过索引方式方便地访问类的数据信息的方法。C#并不将索引类型限制为整数,所以我们可以通过访问器的重载,实现整数索引或者字符串索引。重载索引器时,要保证形参的数量或形参类型至少有一不同。这一点同C#中方法重载貌似没有什么区别。下面我们就通过简单的例子,实现整数索引和字符串索引。在这个例子中,我们需创建两个类 --> Student StudentsStudent类中,包含学生基本信息(属性)和一个方法SayHi()Students类中,包含我们 阅读全文
posted @ 2013-02-22 17:37 yellowshorts 阅读(424) 评论(0) 推荐(0)
摘要:配中文字符的正则表达式: [\u4e00-\u9fa5]匹配双字节字符(包括汉字在内):[^\x00-\xff]应用:计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)String.prototype.len=function(){return this.replace([^\x00-\xff]/g,"aa").length;}匹配空行的正则表达式:\n[\s| ]*\r匹配HTML标记的正则表达式:/<(.*)>.*<\/\1>|<(.*) \/>/ 匹配首尾空格的正则表达式:(^\s*)|(\s*$)应用:javascri 阅读全文
posted @ 2013-02-20 16:23 yellowshorts 阅读(357) 评论(0) 推荐(0)
摘要:string num=12num.PadLeft(4, '0'); //结果为为 '0012'看字符串长度是否满足4位,不满足则在字符串左边以"0"补足 阅读全文
posted @ 2013-02-19 14:59 yellowshorts 阅读(5360) 评论(0) 推荐(0)
摘要:int[] numbers=new int [20]; //建立一个数组 Random rand=new Random (); //生成随机数 string result=""; //保存结果 for (int i = 0; i < 20; i++) //初始化数组 numbers[i] = i+1; for (int i = 0; i < 20; i++) //洗牌{int temp = rand.Next(20); int tempNumber = numbers[i ]; numbers[i] = numbers[temp ]; numbers[temp] 阅读全文
posted @ 2013-02-19 14:56 yellowshorts 阅读(301) 评论(0) 推荐(0)
摘要:<%@ OutputCache Duration="15" VaryByParam="none" %> 使用页面输出缓存<%@ OutputCache Duration="3600" VaryByParam="id" %> 使用参数变化输出缓存<%@ OutputCache Duration="3600" VaryByControl="DropDownList1" %> 基于控件变化的输出缓存<%@ OutputCache Durat 阅读全文
posted @ 2013-02-18 16:26 yellowshorts 阅读(224) 评论(0) 推荐(0)