随笔分类 -  C#web应用知识

摘要:我们常将内容放在Panel中,例如文章,GridView控件等....。当内容超出Panel的高、宽时,可能就需要滚动条来进行控制。 当点击页面中按钮产生PostBack时,滚动条总是会回到最上面的位置,我们现在要解决的主要就是这个问题。ScrollBar的可选项有: 成员名称说明 Auto根据需要,可显示水平滚动条、垂直滚动条或这两种滚动条。要不然也可以不显示任何滚动条。 Both同时显示水平滚动条和垂直滚动条。 Horizontal只显示水平滚动条。 None不显示滚动条。 Vertical只显示垂直滚动条。 演示如何控制ScrollBars的Demo,基本思路是通过两个HiddenFie 阅读全文
posted @ 2011-03-11 14:54 小锋神 阅读(12969) 评论(0) 推荐(0)
摘要:public string SendMsg(string user,string password,string phone,string text) { try { //if (!Regex.IsMatch(phone, @"^(13|15)\d{9}$")) // return "手机号码格式错误!"; string url = "http://www.xunsai.net:8000/"; string param = "user=" + user+ "&password=" + p 阅读全文
posted @ 2011-02-23 09:37 小锋神 阅读(382) 评论(0) 推荐(0)
摘要:问题:asp.net2.0用登陆控件经常会出现:回发或回调参数无效。在配置中使用<pagesenableEventValidation="true"/>或在页面中使用<%@PageEnableEventValidation="true"%>启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用ClientScriptManager.RegisterForEventValidation方法来注册回发或回调数据以进行验证。说明:执行当前Web请求期间,出现未 阅读全文
posted @ 2011-02-16 10:02 小锋神 阅读(6479) 评论(0) 推荐(0)
摘要://由dataset导出Excel public void CreateExcel(DataSet ds,string typeid,string FileName) { HttpResponse resp; resp = Page.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName); 阅读全文
posted @ 2011-02-13 10:32 小锋神 阅读(1384) 评论(1) 推荐(0)
摘要:父窗口弹出子窗口的 button处理事件: private void butDeta_Click(object sender, System.EventArgs e) { Response.Write("<script>window.open('CangkuDetaList.aspx?strMateNo="+ txtMateNo.Text +"&strWaretype="+ ddlWareType.SelectedValue +"','new1','width=750,height=4 阅读全文
posted @ 2011-01-26 14:40 小锋神 阅读(2864) 评论(0) 推荐(0)
摘要:1、admins目录访问时转到admins/login.aspx2、other.aspx访问时转到login.aspx配置文件设置拒绝other.aspx和admins目录,默认登录页面为login.aspx,并设置允许匿名访问admins/login.aspx】<configuration><system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx"> </forms> </authentication&g 阅读全文
posted @ 2011-01-23 23:49 小锋神 阅读(2587) 评论(0) 推荐(1)
摘要:鼠标经过表格变色样式:<style> table { background-color:#000000; cursor:hand; width:100%; } td { /*设置onmouseover事件*/ onmouseover: expression(onmouseover=function (){this.style.borderColor ='blue';this.style.color='red';this.style.backgroundColor ='yellow'}); /*设置onmouseout事件*/ onmo 阅读全文
posted @ 2011-01-18 16:36 小锋神 阅读(7108) 评论(0) 推荐(0)
摘要:如果你想让鼠标移到按钮上更改背景颜色,移出后恢复,一般用以下代码,那能不能把他写成自定义控件呢?<asp:ButtonID="Button1"runat="server"onmouseover="this.style.backgroundColor='DodgerBlue';this.style.color='black';"onmouseout="this.style.backgroundColor='Silver';this.style.color='blac 阅读全文
posted @ 2011-01-16 22:23 小锋神 阅读(1978) 评论(0) 推荐(0)
摘要:设当前页完整地址是:http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.jb51.net"是域名 "aaa"是站点名 "bbb.aspx"是页面名(文件名) "id=5&name=kelli"是参数 【1】获取 完整url (协议名+域名+站点名+文件名+参数) string url=Request.Url.ToString(); url= http://www.jb51.net/aaa/bbb. 阅读全文
posted @ 2011-01-14 15:37 小锋神 阅读(812) 评论(1) 推荐(0)
摘要:用DirectoryInfo搜索文件夹时过滤隐藏文件夹2009-07-04 11:50用DirectoryInfo.GetDirectories();搜索文件夹的时候。总是连隐藏的也搜索出来。有的时候我不需要连隐藏的文件夹也搜索出来。而且一般情况下隐藏文件夹都是不允许访问的多。要过滤掉隐藏文件夹。可以这样做:DirectoryInfo di = new DirectoryInfo(搜索的路径); //实例化DirectoryInfoDirectoryInfo[] dir = di.GetDirectories(); //使用GetDirectories方法获取文件夹信息foreach (Dir 阅读全文
posted @ 2011-01-03 09:22 小锋神 阅读(2682) 评论(0) 推荐(1)
摘要:根据月份算这个月的天数。C# code DateTime d = new DateTime(2008,8,8); System.Globalization.Calendar c = new System.Globalization.GregorianCalendar(); int daysInAugust = c.GetDaysInMonth(d.Year, d.Month); // 31法定节假日that is a bit difficult, you might:C# code DateTime[] m_Holidays = new DateTime[] { new DateTime(20 阅读全文
posted @ 2010-12-24 11:00 小锋神 阅读(691) 评论(0) 推荐(1)
摘要:/************************ *用第二个方法,获取远程文件的大小 *************************///1.判断远程文件是否存在 ///fileUrl:远程文件路径,包括IP地址以及详细的路径private bool RemoteFileExists(string fileUrl) { bool result = false;//下载结果 WebResponse response = null; try { WebRequest req = WebRequest.Create(fileUrl); response = req.GetResponse(); 阅读全文
posted @ 2010-12-21 16:36 小锋神 阅读(5653) 评论(2) 推荐(1)
摘要:字符串函数对二进制数据、字符串和表达式执行不同的运算。此类函数作用于CHAR、VARCHAR、 BINARY、 和VARBINARY 数据类型以及可以隐式转换为CHAR 或VARCHAR的数据类型。可以在SELECT 语句的SELECT 和WHERE 子句以及表达式中使用字符串函数。常用的字符串函数有:一、字符转换函数1、ASCII()返回字符表达式最左端字符的ASCII 码值。在ASCII()函数中,纯数字的字符串可不用‘’括起来,但含其它字符的字符串必须用‘’括起来使用,否则会出错。2、CHAR()将ASCII 码转换为字符。如果没有输入0 ~ 255 之间的ASCII 码值,CHAR() 阅读全文
posted @ 2010-12-21 10:53 小锋神 阅读(206) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;using System.Data;using System.Xml;using System.Xml.Xsl;using System.IO;using System.Data.OleDb;using System.Data.Odbc;using System.Text;us 阅读全文
posted @ 2010-12-19 22:05 小锋神 阅读(1107) 评论(0) 推荐(0)
摘要:protected void Page_Load(object sender, EventArgs e) { string paths = Server.MapPath(""); DataSet ds3= getcsv(paths, paths+"2010年淘趣后台导入价格表样式20100828.csv"); GridView1.DataSource = ds3; GridView1.DataBind(); } private DataSet getcsv(string filepath, string file... 阅读全文
posted @ 2010-12-19 21:34 小锋神 阅读(1431) 评论(0) 推荐(0)
摘要:using System;using System.Data;using System.Configuration;using System.Collections;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;public partial class Page : System.Web.UI.Page{p 阅读全文
posted @ 2010-12-19 21:02 小锋神 阅读(201) 评论(0) 推荐(0)
摘要:using System;using System.Data;using System.Configuration;using System.Collections;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;public partial class Page : System.Web.UI.Page{p 阅读全文
posted @ 2010-12-19 21:02 小锋神 阅读(186) 评论(0) 推荐(0)
摘要:1. 打开新的窗口并传送参数: CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="++"')</script>")2.为按钮添加对话框CodeCode hig 阅读全文
posted @ 2010-12-16 15:50 小锋神 阅读(352) 评论(0) 推荐(0)
摘要:int GetAppearTimes(string str1,string str2){ int i=0; while(str1.IndexOf(str2)>=0){ str1=str1.Substring(str1.IndexOf(str2)+str2.Length); i++; } return i; } int GetAppearTimes(string str1,string str2){ Regex ex=new Regex(str2); return ex.Matches(str1).Count; } Regex.Matches(str1,str2).Count;本文来自CS 阅读全文
posted @ 2010-12-09 17:11 小锋神 阅读(6906) 评论(0) 推荐(1)
摘要:if (drt.HasRows) { while (drt.Read()) { ddl_color.Items.Add(drt.GetString(0));//绑定第一个字段 } Label68.Visible = false; } 阅读全文
posted @ 2010-11-26 15:18 小锋神 阅读(1226) 评论(0) 推荐(0)