随笔分类 -  .Net技巧

xmlhttp调用后台
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--<scriptlanguage="javascript"type="text/javascript">functionCallServer(url){//xml=newActiveXObj... 阅读全文

posted @ 2010-04-01 17:47 优雅小猪 阅读(318) 评论(0) 推荐(0)

asp.net上传多个文件
摘要:上传一个或者多个文件需要把form写成这样:<form method="post" id="form1" onsubmit="/*postForm();return false;*/" action="Default.aspx" style="margin:0px;" runat="server" enctype="multipart/form-data"> 选择上传图片: <b... 阅读全文

posted @ 2010-03-24 14:15 优雅小猪 阅读(2180) 评论(2) 推荐(1)

web后台运行任务(zz)
摘要:在复杂的业务应用程序中,有时候会要求一个或者多个任务在一定的时间或者一定的时间间隔内计划进行,比如定时备份或同步数据库,定时发送电子邮件,定期处理用户状态信息,支付系统中定期同步异常账单等等,我们称之为计划任务。实现计划任务的方法也有很多,可以采用SQLAgent执行存储过程,采用Windows任务调度程序来实现,也可以使用Windows服务来完成我们的计划任务,这些方法都是不错的解决方案。但是,... 阅读全文

posted @ 2009-07-29 13:52 优雅小猪 阅读(1318) 评论(0) 推荐(0)

placeholder LiteralControl从后台生成前台控件
摘要:string str = "<input type='text'></input>";this.p1.Controls.Add(new LiteralControl(str)); 阅读全文

posted @ 2009-01-16 21:52 优雅小猪 阅读(370) 评论(0) 推荐(0)

错误配置
摘要: 阅读全文

posted @ 2008-12-31 23:44 优雅小猪

一个Reapter的例子
摘要:default.aspx Title Artist Country Company Price Year cdcatalog.xml Empire Burlesque Bob Dylan USA Columbia 10.90 1985 Hide your heart Bonnie Tyler U... 阅读全文

posted @ 2008-12-27 10:37 优雅小猪 阅读(600) 评论(1) 推荐(0)

大量字符串连接,StringBuilder效率果然高
摘要:ATT 阅读全文

posted @ 2008-12-24 11:21 优雅小猪 阅读(215) 评论(0) 推荐(0)

asp.net单个文件上传和多个文件上传
摘要:单个文件 .aspx .cs string sPath = Server.MapPath("~") + @"\upload\file\; string FileName = "filename.txt"; UploadFile.PostedFile.SaveAs(sPath + FileName); 多个文件 .aspx .cs HttpFileCollection file... 阅读全文

posted @ 2008-12-24 10:13 优雅小猪 阅读(340) 评论(0) 推荐(0)

System.Web.HttpUtility.UrlEncode
摘要:首先要添加System.Web.dll的引用 string CarID = "浙A12345"; string UrlEncodeCarID=System.Web.HttpUtility.UrlEncode(CarID); 阅读全文

posted @ 2008-12-11 15:12 优雅小猪 阅读(1217) 评论(0) 推荐(0)

Reapter和数据绑定表达式
摘要:用Reapter可以显示类似新闻公告等 用数据绑定表达式: 一个例子: http://www.w3school.com.cn/aspnet/aspnet_repeater.asp 另外:Reapter控件的内容如果为html,则会解析为html,而gridview莫非不会解析,而是作为普通文本,如果想要解析为html效果,需要BoundField对应的HtmlEncode设置为false 阅读全文

posted @ 2008-12-06 14:53 优雅小猪 阅读(1553) 评论(0) 推荐(0)

将一个或多个空格替换成为一个空格
摘要:string test = "aa bb cc dd"; string result = System.Text.RegularExpressions.Regex.Replace(test, @" +", " "); MessageBox.Show(result); 阅读全文

posted @ 2008-11-04 17:21 优雅小猪 阅读(1874) 评论(0) 推荐(0)

System.Collections.Generic.List<>是System.Collections.ArrayList的泛型实现
摘要:System.Collections.Generic.List<>是System.Collections.ArrayList的泛型实现 阅读全文

posted @ 2008-09-13 20:53 优雅小猪 阅读(948) 评论(1) 推荐(0)

string.TrimEnd()在分割串中的利用
摘要:经常用到在循环中,把若干个字符串用某个标记分割后连接起来,最后尾巴上往往还带有一个多于的分割符。去掉的方法很多。用String.TrimEnd('分割符')也是很方便的,并且也不用判断字符串的长度。和string.Split一样,参数char[]可以用'c'直接输入 阅读全文

posted @ 2008-09-13 15:30 优雅小猪 阅读(526) 评论(0) 推荐(0)

表驱动法(zz:http://www.cnblogs.com/shinn/archive/2008/04/16/1157141.html)
摘要:private static double[] rangeLimit = { 60.0, 75.0, 85.0, 95.0,100.0 };private static string[] grade = {"不合格", "合乎要求", "良好", "优秀" ,"卓越"};private static readonly int maxLevel = grade.Length - 1;public s... 阅读全文

posted @ 2008-09-13 12:07 优雅小猪 阅读(791) 评论(0) 推荐(0)

短信模板(在SQL中利用replace函数完成替换)
摘要:模板:[OwnerName][OwnerTitle],您好!我是[ProjectName]保险公司业务员[UserName],您的[QuoteContent],不清楚可联系服务电话:(公司[ProjectContactPhone])或(个人[UserMobilePhone]),谢谢您的查收!祝您身体健康!任务:将[……]的内容用实际内容进行替换代码: string sql ... 阅读全文

posted @ 2008-09-12 12:12 优雅小猪 阅读(1509) 评论(0) 推荐(0)

typeof,gettype,is,as
摘要:public class testclass { public string s = ""; public int i = 0; } testclass o = new testclass();System.Type t1 = typeof(testclass);System.Type t2 = o.GetType();if (o is testclass){MessageBox.Show("o ... 阅读全文

posted @ 2008-09-02 16:43 优雅小猪 阅读(477) 评论(0) 推荐(0)

XML文件简单操作
摘要:1读取XML文件using System.Xml;public static string GetAppSetting(string appSettingName){ XmlDocument _settings = new XmlDocument(); string FileName = System.IO.Path.GetDirectoryName(System.Reflection.Asse... 阅读全文

posted @ 2008-08-19 14:57 优雅小猪 阅读(237) 评论(0) 推荐(0)

Application.DoEvents
摘要:private void button1_Click(object sender, EventArgs e) { Application.DoEvents(); this.label1.Text = "步骤1"; Application.DoEvents(); System.Threading.Thread.Sleep(5000); Application.DoEvents(); this.lab... 阅读全文

posted @ 2008-06-12 22:17 优雅小猪 阅读(639) 评论(0) 推荐(0)

windows mobile中使用datagrid绑定并显示数据及得到界面显示的数据值
摘要:1 绑定数据源,设置显示列和显示格式等 if (ds!= null) { this.dataGrid_Fix.DataSource = ds; } DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = "Table1"; DataGridColumnStyle ID = new DataGridTextBoxColum... 阅读全文

posted @ 2008-05-23 11:32 优雅小猪 阅读(6342) 评论(1) 推荐(0)

判断字符串中是否含有汉字
摘要:1.判断是否含有汉字using System.Text.RegularExpressions;if (Regex.IsMatch("abc->", @"[\u4e00-\u9fa5]+")){Console.WriteLine("字符串中有汉字");}else{Console.WriteLine("字符串中无汉字");}2判断字符串是否全为汉字if (Regex.IsMatch("我你a",... 阅读全文

posted @ 2008-05-22 14:43 优雅小猪 阅读(1254) 评论(0) 推荐(0)

导航