易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET小技巧

最近访问了建行网站时 https://ibsbjstar.ccb.com.cn/V5/index.html#,(其实在oblog,http://www.oblog.cn也采用了类似的技巧,不过方法不同罢了)
  可以发现,当选择不同的文本框,可以出现不同的颜色,要完成这个功能很简单,但是如果有很多类似的功能,如果一个个设置控件样式显然很累,一个简单的处理方法写一个方法让系统执行就可以了,看如下代码:
class BasePage:Page
{
public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)
{
foreach (Control ctl in container.Controls)
{
if ((onlyTextBoxes && ctl is TextBox)    ctl is TextBox    ctl is DropDownList   
ctl is ListBox    ctl is CheckBox    ctl is RadioButton   
ctl is RadioButtonList    ctl is CheckBoxList)
{
WebControl wctl = ctl as WebControl;
wctl.Attributes.Add("onfocus", string.Format("this.className = '{0}';", className));
wctl.Attributes.Add("onblur", "this.className = '';");
}
else
{
if (ctl.Controls.Count > 0)
SetInputControlsHighlight(ctl, className, onlyTextBoxes);
}
}
}
}
  定义一个类:主要就是重写onfocus和onblur,当用户选择不同控件时,就出现不同的样式,样式名称需要你自己定义。
  这里需要注意:这个BasePage是从Page类派生,所以,以后建立页面时应该是:
WebForm1:MyPage
{
//调用SetInputControlsHighlight方法
}


相关文档:

asp.net Excel导入&导出


1、Excel数据导入到数据库中:
//该方法实现从Excel中导出数据到DataSet中,其中filepath为Excel文件的绝对路径,sheetname为表示那个Excel表;
        public DataSet ExcelDataSource( string filepath , string sheetname )
&nb ......

ASP.NET 2.0 中的SqlCacheDependency特性


   
   它还会在指定的数据库中增加几个存储过程,用来让ASP.NET引擎查询追踪的数据表的情况。
   
   然后,它会给我们要追踪的Table加上几个Trigger,分别对应到Insert、Update、Delete操作,这几个Trigger的语句非常简单,就是把“AspNet_SqlCacheTablesF ......

ASP.NET去掉HTML标记

using System;
using System.Web;
using System.Text.RegularExpressions;
public static string NoHTML(string Htmlstring)  
  {  
   //删除脚本  
   Htmlstring   =   Regex.Replace(Htmlstring,@"<script[^>]*?>.*?&l ......

在ASP.NET中上传图片并生成缩略图的C#源码

http://www.knowsky.com/5723.html
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls; ......

ASP.NET AJAX 使用客户端调用服务器端的方法

  Microsoft ASP.NET AJAX可以很方便的让我们在客户端使用脚本调用ASP.NET Web
Services(.asmx),要启用这一特性,像前面提到的一样,必须要配置Web.Config,可以参照Microsoft ASP.NET
AJAX安装目录下的Web.Config,如果是通过ASP.NET AJAX-enabled Web
site模版建立的站点,则不需要再进行设置了。配置节点如下 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号