1、GridView导出Excel
2007年9月小记        StringWriter sw = new StringWriter();
2007年9月小记        HtmlTextWriter hw 
= new HtmlTextWriter(sw);
2007年9月小记        
this.grvColumnLogList.RenderControl(hw);
2007年9月小记
2007年9月小记        Response.Clear();
2007年9月小记        Response.ContentType 
= "application/vnd.ms-excel";
2007年9月小记        Response.Charset 
= "utf-8";
2007年9月小记        Page.EnableViewState 
= false;
2007年9月小记
2007年9月小记        Response.AppendHeader(
"Content-Disposition""attachment;filename=MyExcel.xls");
2007年9月小记        Response.Write(
"<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\"><title>Copyright by CJB</title></head><body><center>");
2007年9月小记        Response.Write(sw.ToString());
2007年9月小记        Response.Write(
"</center></body></html>");
2007年9月小记        Response.End();
需要添加以下override
2007年9月小记    public override void VerifyRenderingInServerForm(Control control)
    }

http://www.cnblogs.com/stswordman/archive/2006/08/24/485641.html
http://www.cnblogs.com/powerlc/archive/2005/08/27/223989.html

2、CheckBoxList的全选。
2007年9月小记    <script type="text/javascript" language="javascript">
2007年9月小记        
function doSelectThis(cbl)
>

2007年9月小记        <asp:CheckBoxList ID="cblColumns" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" onclick="doSelectThis(this)" ></asp:CheckBoxList>
2007年9月小记
2007年9月小记        
<asp:CheckBox ID="chbAllSelected" runat="server" Text="全选" onclick="doSelectAll(this);" />

3、固定form的action,避免在多段URL重写的无刷新分页中出现404错误
2007年9月小记    Sys.Application.add_load(function()
);

4、302与301对搜索引擎的影响。
301 redirect: 301代表永久性转移(Permanently Moved),301重定向是网页更改地址后对搜索引擎友好的最好方法,只要不是暂时搬移的情况,都建议使用301来做转址。
302 redirect: 302代表暂时性转移(Temporarily Moved ),在前些年,不少Black Hat SEO曾广泛应用这项技术作弊,目前,各大主要搜索引擎均加强了打击力度,象Google前些年对Business.com以及近来对BMW德国网站的惩罚。即使网站客观上不是spam,也很容易被搜寻引擎容易误判为spam而遭到惩罚。
而Response.Redirect方法返回的正是302,如果对于永久性移除的URL,并且希望它在SEC的记录转移到新的URL中,需要改为301重写向
例如:
2007年9月小记    protected void Page_Load(object sender, EventArgs e)
    }

5、 如何利用客户端缓存对网站进行优化? 
2007年9月小记    protected void Page_Load(object sender, EventArgs e)
    }

7、在SQL2005里如何清空事务日志文件?
先把数据库属性改成“简单”,然后收缩日志文件

8、获取随机记录
select * from table order by newid()

相关文章: