1、当在VS2005中卸载一个现有的项目再移除项目后,编译网站时会出现错误——项目""不在解决方案中,不能编译,解决方法以下:
右键网站->属性页->引用->把列表中刚移除的项目的引用删除->OK^^
2、当用cookies保存中文时,需要用到HttpUtility.Encode、Decode对中文进行编码,不然会乱码。详细可参考以下网址:
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;313282 3、如何在XHTML中循环反向输出XML的节点内容? 解决方法是需在xslt文件中设置xsl:sort属性,例如:
< xsl:sort order ="descending" /> //设置循环方式
< li >
< xsl:value-of select ="@Date" />
< xsl:value-of select ="@Chn" />
</ li >
</ xsl:for-each >
4、轻松筛选掉DataTable中的重复行
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5、设置随机数种子
6、获取数据库用户表
type AS TYPE, crdate AS DATE_CREATED
FROM sysobjects
where xtype = ' U ' and name <> ' dtproperties '
order by [ name ]
7、获取数据库用户视图
type AS TYPE, crdate AS DATE_CREATED
FROM sysobjects
WHERE (type = N ' V ' ) AND ( permissions (id) & 4096 <> 0 ) AND ( ObjectProperty (id,
N ' IsMSShipped ' ) = 0 )
order by [ name ]
8、获取表的字段定义信息
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9、获取表或视图的字段名称
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
select a.name as N'字段名'
from syscolumns a inner join sysobjects d
on a.id=d.id and (d.xtype='U' or d.xtype='V') and d.name<>'dtproperties' and d.name='Order Details Extended'
order by object_name(a.id),a.colorder
10、获取所有数据库名
11、获取系统所有定义颜色
foreach ( object colorName in colors )
{
defaultColors.Add(Color.FromName(colorName.ToString()));
}
12、匹配url的正则表达式
13、匹配特定的html标签
14、用javascript防止重复提交表单
{
btn.value = " 正在提交
![](https://www.cnblogs.com/Images/dot.gif)
btn.disabled = true ;
}
使用时,只要把button的OnClientClick属性设为SubmitOnce(this),并设UseSubmitBehavior为false,不然不能触发按钮事件。UseSubmitBehavior需设为false的原因,可参考以下两篇文章:
禁用(灰化) Button 后提交的问题
ASP.Net随想_服务器控件的页面请求模型
15、在关闭页面前提示
return " the text will lose. " ; // 返回文本会在弹出对话框中显示
}
事件函数可以设一个返回值作为该对话框的显示文本。
16、动态输出用户控件内容
假如有用户控件MyUserControl,具有属性GroupId,现在需要在单击页面上某按钮后,动态输出控件的HTML内容到word中,可以使用以下代码:
{
Page tPageHoder = new Page(); // 创建用户控件加载处理页面
MyUserControl control = (MyUserControl )tPageHoder.LoadControl( " ~/Module/MyUserControl.ascx " );
control.GroupId = groupId; // 属性赋值
tPageHoder.Controls.Add(control); // 把用户控件加载页面控件树
HttpContext.Current.Server.Execute(tPageHoder, output, false ); // 执行页面处理流程,并把最后内容输出保存
PageHelper.ExportToWord(output.ToString()); // 输出到word
}
17、Sql Server数据库由单用户模式改为多用户模式
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
GO
DECLARE @SQL VARCHAR ( MAX );
SET @SQL = ''
SELECT @SQL = @SQL + ' ; KILL ' + RTRIM (SPID)
FROM master..sysprocesses
WHERE dbid = DB_ID ( ' [DBName] ' ); -- [DBName]是把数据库修改为单用户模式的执行数据库
EXEC ( @SQL );
GO
ALTER DATABASE [ DBName ] SET MULTI_USER; -- 这里[DBName]是要修改为多用户的数据库名