随笔分类 -  asp.net

摘要:Session:在服务器的内存中;Cookie:在客户端的浏览器中;一般在使用Session的时候,都会有一个实体类,用于存储用户名等数据,所以在这里我们定义一个类;里面就放两个字段:用户名,和密码;publicclassUserTest{publicstringUserName{get;set;}publicstringUserPwd{get;set;}}然后我们要获取存数据来源stringuserName=this.txtLoginId.Text.Trim();stringuserPwd=this.txtLoginPwd.Text.Trim();接着就是把数据放到Session中了。Us. 阅读全文
posted @ 2011-06-17 19:42 ゞ追忆o0ゞ 阅读(3579) 评论(1) 推荐(1)
摘要:这两天不知道咋的了,突然迷上了写控制台上的程序,写多了,会发出很多小算法很有意思,多多练习,多多积累,让基础知识越来越牢固。还是两个for循环,外层循环行数,内层循环列数;代码:usingSystem;namespace_99乘法表{classProgram{staticvoidMain(string[]args){inti,j;for(i=1;i<=9;i++) //循环行{for(j=1;j<i+1;j++) //循环列{Console.Write("{0}*{1}={2}\t",j,i,i*j);}Console.Write("\n") 阅读全文
posted @ 2011-06-12 22:31 ゞ追忆o0ゞ 阅读(1027) 评论(0) 推荐(0)
摘要:都知道两个for循环搞定,大家是怎么记的这两个循环? 外层:循环数组长度; i<数组长度-1 //从0开始循环;内层:循环排序次数; j<数组长度-1-i;备忘代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceHelloACCP{///<summary>///本程序演示使用二重循环实现数组的冒泡排序算法///</summary>classProgram{staticvoidMain(string[]args){int[]scores=newint[5];inti, 阅读全文
posted @ 2011-06-12 21:10 ゞ追忆o0ゞ 阅读(977) 评论(0) 推荐(0)
摘要:要求:1.行数取3--21之间,对非法行数抛出"非法行数";2. 在控制台上打印出这个行数的倒三角形;如图实现代码:staticvoidMain(string[]args){intintNumber;Console.Write("请输入显示的行数:");stringnumber=Console.ReadLine();boolIsNum=int.TryParse(number,outintNumber);if(!IsNum){Console.Write("请不要输入非法数字!");}elseif(intNumber<3||intN 阅读全文
posted @ 2011-06-10 00:50 ゞ追忆o0ゞ 阅读(4323) 评论(1) 推荐(0)
摘要:例如:http://www.baidu.com/view.aspx?id=1 和http://www.baidu.com/view-1.aspx 访问的页面相同;只需要全局应用程序类的Application_BeginRequest中添加如下代码:protectedvoidApplication_BeginRequest(objectsender,EventArgse){//使用正则表达式判断格式;View-12.aspxRegexreg=newRegex(@".+View-(\d+).aspx");//获取请求的路径进行匹配varmatch=reg.Match(Reque 阅读全文
posted @ 2011-05-21 16:45 ゞ追忆o0ゞ 阅读(390) 评论(0) 推荐(0)
摘要:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.SessionState;namespace全局应用程序类Global应用{publicclassGlobal:System.Web.HttpApplication{protectedvoidApplication_Start(objectsender,EventArgse){//程序第一次运行;}protectedvoidSession_Start(objec 阅读全文
posted @ 2011-05-21 15:52 ゞ追忆o0ゞ 阅读(1383) 评论(0) 推荐(0)
摘要:只要在Web.Config中添加如下代码即可。 <system.web><customErrorsmode="On"defaultRedirect="~/Error.aspx" <!--全局性的 推荐mode为RemoteOnly:本机查看详细错误信息,其他机器查看定制的错误页面 --><errorstatusCode="404"redirect="~/404.html"/> <!--局部性的,可以添加404,403等已知错误--></customErro 阅读全文
posted @ 2011-05-18 17:46 ゞ追忆o0ゞ 阅读(332) 评论(0) 推荐(0)
摘要:行数:GridView1.Rows.Count;列数:GridView1.Columns.Count; 阅读全文
posted @ 2011-05-18 16:21 ゞ追忆o0ゞ 阅读(7198) 评论(0) 推荐(0)
摘要:第三方控件下载地址:http://www.webdiyer.com/Controls/AspNetPager/Downloads实现最基本的高效分页 需要两个存储过程,第一个是获取全部数据数量的SQL,第二个是分页用的SQL语句了先上SQL代码:分页用的存储过程CREATEPROCEDUREProc_GridView_Pager@startIndexint,@endIndexintASBEGINselect*from(selecta.id,a.saleName,a.price,a.count,a.amount,b.Name,a.inDate,row_number()over(orderbya. 阅读全文
posted @ 2011-05-18 13:26 ゞ追忆o0ゞ 阅读(432) 评论(0) 推荐(0)
摘要:HeaderTemplateRowDataBound设置GirdView 的DataKeyNames="Name"即数据源中的字段,我设置的是:Name; 添加GridView事件: RowDataBound 在事件事首先判断行的类型是不是数据行;因为第一行通常是 HeaderTemplate;(图中的第一行就是表头,如编号,标识码,商品名称。。。。) 在当前行中查换DropDownList的Id;DropDownListddlInType=e.Row.FindControl("ddlInType")asDropD... 阅读全文
posted @ 2011-05-17 07:55 ゞ追忆o0ゞ 阅读(4427) 评论(0) 推荐(0)
摘要:foreach(GridViewRowgvringvInBillList.Rows){TextBoxt=gvr.FindControl("TextBox1")asTextBox;if(t!=null){t.Text="给TextBox1赋值";}}这个方法真的很实用;把代码放到Page_Load中;其实在GridView的模板中操作真挺头疼的;也许是我真的好菜好菜;其实其他控件还好,最疼头的应该是DropDownList吧,这个方法同样受用;protectedvoidPage_Load(objectsender,EventArgse){if(!IsPos 阅读全文
posted @ 2011-05-16 14:32 ゞ追忆o0ゞ 阅读(3999) 评论(0) 推荐(0)
摘要:protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse){EnableViewState=false;if(e.Row.RowType==DataControlRowType.DataRow){e.Row.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#CCCCFF'");e.Row.Attributes. 阅读全文
posted @ 2011-05-16 09:35 ゞ追忆o0ゞ 阅读(372) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-05-16 05:30 ゞ追忆o0ゞ 阅读(6) 评论(0) 推荐(0)
摘要:1, 获取当前行的行号: int index = ((ListViewDataItem)e.Item).DisplayIndex;2,获取当前行的主键: int id = Convert.ToInt32(ListView1.DataKeys[index].value);protectedvoidListView1_ItemCommand(objectsender,ListViewCommandEventArgse){//获取当前行号;intindex=((ListViewDataItem)e.Item).DisplayIndex;//获取当前行号的主键;intid=Convert.ToInt3 阅读全文
posted @ 2011-05-12 11:53 ゞ追忆o0ゞ 阅读(456) 评论(0) 推荐(1)
摘要:在Aspx页中的代码:<EditItemTemplate><asp:DropDownListID="DropDownList1"runat="server"><asp:ListItemValue="男">男</asp:ListItem><asp:ListItemValue="女">女</asp:ListItem></asp:DropDownList></EditItemTemplate>添加事件:ItemUpdating 阅读全文
posted @ 2011-05-11 06:23 ゞ追忆o0ゞ 阅读(1955) 评论(0) 推荐(0)
摘要:教程地址:http://www.cnblogs.com/atao/category/209358.htmlNPOI文件包:http://u.115.com/file/aqr5pjb7程序源码:http://u.115.com/file/bhvr12dq代码中数据库链接字符串自己修改,还有对应的字段名之类的信息;新建一个Handler.ashx(一般处理程序) 代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Data;usingSystem.Data.Sql 阅读全文
posted @ 2011-05-05 04:43 ゞ追忆o0ゞ 阅读(2619) 评论(3) 推荐(1)
摘要:如果直接在页面中使用Response.Write("<script>alert('错误信息');</script>"); 点击确定以后,可能会造成页面“错位”;把代码封装到一个类中(就叫PageHelper.cs吧),在其他页面也可以方便的调用;例如在其他页面调用:Page.Alert(this,"错语信息"); 效果和上面的代码是一样的,要说不同点吧?就是这个写法比上面的完美好多。调用的时候也可以有第二个参数,即转跳地址: Page.Alert(this,"警告提示~","~/Def 阅读全文
posted @ 2011-05-04 01:50 ゞ追忆o0ゞ 阅读(6438) 评论(6) 推荐(1)
摘要:不是很漂亮,只是用于研究其原理;是新建了一个ashx文件(一般处理程序,因为我还在学习中……)在aspx页中的form表单中添加调用;<img src="验证码实例.ashx" alt="" />usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Drawing;usingSystem.Drawing.Imaging;usingSystem.Web.SessionState;namespaceWebApp{///< 阅读全文
posted @ 2011-05-03 07:16 ゞ追忆o0ゞ 阅读(450) 评论(0) 推荐(0)
摘要:今天在看视频教程的时候,听到“杨中科”老师说有很多大公司,在面试的时候常常问一些基础的东西,甚至常问你一些简单到“变态”的题,对于我们做Web开发来说,突然问你一些算法题,也许有好多人当时的脑子是空白的;杨老师说例如问到从1加到100的算法,有很多程序员都写不出来;今天在这里,我用一种数学公式来算出这道题~首先要知道从1加到100的数式; n*(n-1)/2+n; 大家都知道从1加到100等于5050; 不妨用这个公式套一下,看看等不等于5050;n就是从1加到第几的数字; 100*(100-1)=9900; 9900/2=4950; 4950+100=5050; 看来这个公式是行的通的;所以 阅读全文
posted @ 2011-04-27 17:29 ゞ追忆o0ゞ 阅读(18376) 评论(45) 推荐(3)
摘要:我们学过的Code分离到不同文件的方法,主要包括:程序集.dll、<inherits src>.cs、<script src>.cs、用户控件.ascx、include、Response.WriteFile()程序集.dll:这是最高级的方法,它引用的是一个被编译为IL的DLL(程序集)文件。<inherits src>.cs:用这种方法,可以先定义一个继承Pa... 阅读全文
posted @ 2010-03-22 15:17 ゞ追忆o0ゞ 阅读(1223) 评论(0) 推荐(0)