随笔分类 - ASP.NET
摘要:-- For tableEXECUTE sp_addextendedproperty N'MS_Description', '描述内容', N'user', N'dbo', N'table', N'表名', NULL, NULL-- For columnEXECUTE sp_addextendedp...
阅读全文
摘要:1、选择排序选择排序class SelectionSorter { private int min; public void Sort(int[] arr) { for (int i = 0; i < arr.Length - 1; ++i) { min = i; for (int j = i + 1; j < arr.Length; ++j) { if (arr[j] < a...
阅读全文
摘要:protected void Page_Load(object sender, EventArgs e) { //queue 是队列,遵循先进先出的原则 //queue 属性 count // queue method Clear() //清空 //Contains() //是否包含 //Dequeue() //出列 //Enqueue() //入列 ...
阅读全文
摘要:CREATE TABLE test( Id INT IDENTITY(1,1)PRIMARY KEY, NAME VARCHAR(20), ParentId INT )INSERT test VALUES('首页',0)INSERT test VALUES('新闻',1)INSERT test VALUES('国内新闻',2)INSERT test VALUES('国外新闻',2)INSERT test VALUES('社会',3)INSERT test VALUES('军事',3)INSERT t
阅读全文
摘要:string ConnString = @"Data Source=.;Initial Catalog=master;Integrated Security=true;"; private DataTable dt = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dt = new DataTable(); GetMenu...
阅读全文
摘要:postedFile.ContentType得到的是类似这样的属性,如image/gif,text/html==System.IO.Path.GetExtension得到是文件扩展名,如123.txt 中的txt,123.gif 中的gif后坠名如 jpg 文件是可以改的而postedFile.ContentType 是 是很难改变的就算把 xxxx.jpg 改名成 xxxx.gif ContentType仍然是不变的ContentType mime 类型在注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type 下这
阅读全文
摘要:/// <summary> /// 文件上传判断类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpload_Click(objectsender, EventArgs e) { #region 一、 安全性比较低,把文本文件1.txt改成1.jpg照样可以上传,但其实现方法容易理解,实现也简单,所以网上很多还是...
阅读全文
摘要:/// <summary> /// 创建并获取目录,主要用于用户文件上传的目录,目录创建在resources/upload下 /// </summary> /// <param name="customize">自定义类别可以是空NULL,此参数不为空时在upload下会再新建一层目录,如:adminPic则返回../resources/upload/adminPic/年/月/</param> /// <returns>../resources/upload/adminPic/年/月/</returns>
阅读全文
摘要:在Asp.net中,可以有四处设置Session的过期时间:一、全局网站(即服务器)级IIS-网站-属性-Asp.net-编辑配置-状态管理-会话超时(分钟)-设置为120,即为2小时,即120分钟后如果当前用户没有操作,那么Session就会自动过期。二、网站级IIS-网站-具体网站(如DemoSite)-属性-Asp.net,此时有两个选项,一个是“编辑全局配置”,一个是“编辑配置”。如果“编辑全局配置”,就和上个配置一样。如果“编辑配置”,则只对当前网站生效。因为一个服务器可能有很多独立网站。1、继续选择“状态管理”-会话超时(分钟)-设置为360,即360分钟。效果同上,只不过只对当前
阅读全文
摘要:在网站开发时,一般需要设置两个异常页面,如404页面(资源未找到),500页面(系统内部错误,可能由某语句导致的某种异常web.config文件添加如下代码(其它文件不需要设置)1 <customErrors mode="On" defaultRedirect="Error">2 <error statusCode="404" redirect="Error" />3 <error statusCode="500" redirect="~/Error/Ht
阅读全文
摘要:Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('密码修改成功,请重新登陆');window.top.location.href='login.aspx '", true);
阅读全文
摘要:<%# ((RepeaterItem)Container).ItemIndex + 1 %>
阅读全文
摘要:protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["username"] == null || Session["pwd"] == null) { Response.Write("<script>window.top.location.href='login.aspx '</script>"); } } }
阅读全文
摘要://Gridview 分页中设置编号列 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //自动编号 e.Row.Cells[4].Text = (float.Parse(e.Row.Cells[4].Text)*100).ToString(); int index = e.Row.RowIndex;//获取当前点击前的行号 if...
阅读全文
摘要:./当前目录/网站主目录../上层目录~/网站虚拟目录如果当前的网站目录为E:\wwwroot应用程序虚拟目录为E:\wwwroot\company浏览的页面路径为E:\wwwroot\company\news\index.aspx在index.aspx页面中使用Server.MapPath("./")返回路径为:E:\wwwroot\company\newsServer.MapPath("/")返回路径为:E:\wwwrootServer.MapPath("../")返回路径为:E:\wwwroot\companyServer.Ma
阅读全文