晨风

-------------------- 业精于勤,荒于嬉;行成于思,毁于随

导航

随笔分类 -  C#

摘要:Safari浏览器不支持将非ASCII字符存入Cookie,所以中文在保存的时候就会出问题,分号(";")也不能存在Cookie中,所以需要通过方法去除内容中的分号,在Cookie保存非ASCII字符的时候需要通过UrlEncode / UrlDecode方法来编码和解码问题解决Response.Cookies["UserName"].Value = System.Web.HttpUtility.UrlEncode("张波");string UserName = System.Web.HttpUtility.UrlDecode(Res 阅读全文

posted @ 2014-03-19 11:17 shenyixin 阅读(6921) 评论(2) 推荐(2)

摘要:1. 在x64的机子上使用了错误版本的System.Data.SQLite.dll,即x86,需要安装合适版本的System.Data.SQLite.dll,现给出各种找到的下载地址(不保证有效果,毕竟这问题也不是全都相同的):1)http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki2)http://sourceforge.net/projects/sqlite-dotnet2/files/3)安装完后在D:\Program Files (x86)\SQLite.NET\bin\x64(我的程序安装在D盘)这 阅读全文

posted @ 2014-03-18 22:21 shenyixin 阅读(1607) 评论(0) 推荐(0)

摘要:需要在两个地方设置 //Adding a numeric value to "A2" cell string a = "100"; worksheet.Cells["A2"].PutValue(a, true); --①主要是这个,增加一个参数,一般不会用到 //Getting the Style of the A2 Cell style = worksheet.Cells["A2"].GetStyle(); //Setting the display form... 阅读全文

posted @ 2014-03-18 14:59 shenyixin 阅读(5727) 评论(0) 推荐(0)

摘要:protected void Button1_Click(object sender, EventArgs e){ //关闭页面--要弹出提示(IE6及以下不弹出提示) ClientScript.RegisterStartupScript(Page.GetType(), "", ""); //不弹出提示直接关闭页面 ClientScript.RegisterStartupScript(Page.GetType(), "", "");} 阅读全文

posted @ 2013-12-12 16:48 shenyixin 阅读(374) 评论(0) 推荐(0)

摘要:Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入、导出数据非常方便。其中Aspose.Cells就是用来操作Excel的,功能有很多。我所用的是最基本的功能,读取Excel的数据并导入到Dataset或数据库中。读取Excel表格数据的代码如下:首先要引入命名空间:using Aspose.Cells;Workbook workbook = new Workbook();workbook.Open("C:\\test.xlsx");Cells cells = workbook.Worksheets[0].Cells; for 阅读全文

posted @ 2013-10-11 10:56 shenyixin 阅读(1762) 评论(0) 推荐(0)

摘要:当TextBox设置了ReadOnly=true后要是在前台为控件添加了值,后台是取不到的,值为空,多么郁闷的一个问题经过尝试,发现可以通过如下的方式解决这个问题.感兴趣的朋友可以了解下当TextBox设置了ReadOnly="true" 后,要是在前台为控件添加了值,后台是取不到的,值为“空”原理没想通,说不清楚微软是出于什么考虑的,不过有时是要我们能通过前台脚本来填充值,并不希望用户修改其控件内容,这时就比较尴尬了。刚开始是换成Html 里的 ,不过后来发现这个工作量是很大的, 所以网上搜了下,没找出TextBox ReadOnly="true" 页 阅读全文

posted @ 2013-09-12 15:08 shenyixin 阅读(2966) 评论(0) 推荐(1)

摘要:Form最小化是指整个Form都缩小到任务栏上,但是是以Form的标题栏形式显示的, 若是想让Form以Icon的形式显示在任务栏右下角,则需要给Form添加一个NotifyIcon控件, 在使窗体最小化的代码中需要做如下修改:if(this.WindowState==FormWindowState.Normal&&this.Visible==true){ this.notifyIcon1.Visible=true;//在通知区显示Form的Icon this.WindowState=FormWindowState.Minimized; this.Visible=false; 阅读全文

posted @ 2013-07-05 14:28 shenyixin 阅读(13493) 评论(4) 推荐(1)

摘要:最近做单据报表,因为客户要求打印纸有特殊规定,表格列多,但整个报表打印出来不超过宽200mm,想进一切办法的调整,但还是发现问题,比如有这个2个字符串 "TG20111020001","博客园程序员之家" 同是string 类型的字符串,同样设置相同宽度15mm 但效果却是 前者一直撑到字符串长度为止不换行,后者超过规定单元格长度后自动换行,本想要的效果是超过所有列超过设计规格后都自动换行。结果这个问题让页面布局变乱,打印预览时部分列会在第二页打印,或者出现第二页空白页的问题。找了很多办法,最重其实很简单<div style="word- 阅读全文

posted @ 2013-05-15 11:04 shenyixin 阅读(3314) 评论(0) 推荐(0)

摘要:class Program { static void Main(string[] args) { zhishuDemo(100); } /// <summary> /// 求质数(素数) /// </summary> /// <param name="n">范围</param> public static void zhishuDemo(int n) { List<int> list = new List<int>()... 阅读全文

posted @ 2012-12-20 13:08 shenyixin 阅读(283) 评论(0) 推荐(0)

摘要://新建工作簿 Workbook workbook = new Workbook(); //工作簿 Worksheet sheet = workbook.Worksheets[0]; //工作表 Cells cells = sheet.Cells;//单元格 sheet.Protect(ProtectionType.All, "123123", "");//保护工作表 sheet.Protection.IsSelectingLockedCellsAllowed = false;//设置只能选择解锁单元格 sheet.Protection.IsFormat 阅读全文

posted @ 2012-12-06 12:50 shenyixin 阅读(595) 评论(0) 推荐(0)

摘要:public static int Asc(String Data) //获取ASC码 { byte[] b = System.Text.Encoding.Default.GetBytes(Data); int p = 0; if (b.Length == 1) //如果为英文字符直接返回 return (int)b[0]; for (int i = 0; i < b.Length; i += 2) { ... 阅读全文

posted @ 2012-11-01 14:53 shenyixin

摘要:中文:Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息,之所以出现此错误,常见的原因是:通过调用Response.Write()修改相应时,将启用响应筛选器、HttpModules或服务器追踪。详细信息:分析附近的“输出内容”时出错。解决方法如下: 1.如果调用Response.Write()方法的服务器控件在使用UpdatePanel的页面,则只需要在UpdatePanel下增加一个<Triggers>节点,通过PostBackTrigger注册一下改控件就可以了。代码如下: 1. <asp: 阅读全文

posted @ 2012-03-08 15:47 shenyixin 阅读(9074) 评论(4) 推荐(3)

摘要:数据库引擎需要Office2007以上版本using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.OleDb;/// <summary>/// Acces 阅读全文

posted @ 2012-02-23 16:10 shenyixin 阅读(8404) 评论(0) 推荐(1)

摘要:第一种方法:在GridView的模版列里加服务器端控件RadioButton,使用js控制单选<p>使用模版列里加RadioButton</p> <script type="text/javascript"> function setRadio(nowRadio) { var myForm,objRadio; myForm=document.forms[0]; ///alert(myForm);for(var i=0;i<myForm.length... 阅读全文

posted @ 2012-02-21 17:41 shenyixin 阅读(4919) 评论(0) 推荐(0)

摘要:在用Response.Redirect()或Response.Write()进行URL带参数的页面重定向时出现如题所示的错误。1:Ajax是无刷新的,而使用Response进行带参重定向时需要刷新页面。所以只须在UpdatePanel下设置“asp:PostBackTrigger”的“ControlID”为指定的控件名称即可,如: <Triggers> <asp:PostBackTrigger ControlID="btnSave" /> </Triggers>2:如果你用的是微软的ajax框架,弹出提示框应该用: ScriptManag 阅读全文

posted @ 2012-02-20 17:56 shenyixin 阅读(4014) 评论(0) 推荐(2)

摘要:在用easyui控件的时候常用到他能解析的 接送数据,我们可以通过c#将我们从数据库中得到datatable转换成那样的格式,datagrid的好转换,简单的循环拼串就可以,不过 easyui绑定树的时候的接送数据格式稍有不同,比datagrid和datagridtree得到json数据要稍微复杂一些,我写了性能虽然不是很 好的,但是也能得到想要的数据! /// <summary> /// 根据DataTable生成Json树结构 /// </summary> /// <param name="tabel">数据源</param&g 阅读全文

posted @ 2011-12-14 20:29 shenyixin 阅读(6027) 评论(1) 推荐(2)

摘要:using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 {public partial class SelectFolder: Form {public SelectFolder() { InitializeComponent(); }private void btnSelectPath_Cl... 阅读全文

posted @ 2011-12-01 08:42 shenyixin 阅读(10013) 评论(0) 推荐(1)

摘要:List<Plan> Plans = new List<Plan>();//存放服务器中的当前用户所接受的项目计划列表。//Plan 类包含PlanID等属性。 if (Plans.Contains<Plan>(changedPlan, Comparers.Default)){}//判断Plans中是否存在与changedPlan相同的Plan。//(只需判断其PlanID是否相同即可。其他内容可忽略)// Comparers.Default为自定义比较器。 public class Comparers : IEqualityComparer<Plan 阅读全文

posted @ 2011-11-23 18:21 shenyixin 阅读(5122) 评论(0) 推荐(0)

摘要:今天在使用CheckBoxList控件时,突然发现该控件竟然未提供返回当前选中项的属性,比如当前选中项的索引等。它只是提供了获取或设置列表中选定项的最低序号索引,与最低序号索引对应的Text与Value,分别如下:SelectedIndex --获取或设置列表中选定项的最低序号索引。SelectedItem --获取列表控件中索引最小的选定项。SelectedValue --取列表控件中选定项的值,或选择列表控件中包含指定值的项。现在假如我往页面上放了一个CheckBoxList控件,如下:<form id="form1" runat="server&quo 阅读全文

posted @ 2011-11-23 17:20 shenyixin 阅读(4768) 评论(2) 推荐(3)

摘要:aspx页代码:<asp:Repeater ID="rptBlog" runat="server" DataSourceID="objBlog" OnItemDataBound="rptBlog_ItemDataBind"> <ItemTemplate> <div id="rptBlogTitle"> <h3> <a> <%#eval_r( "blogTitle") %> </a> </ 阅读全文

posted @ 2011-09-07 16:11 shenyixin 阅读(1146) 评论(0) 推荐(0)