2013年3月25日 星期一

完成下載時刪除檔案 Delete the file when finish download.


string responseFile = Server.MapPath("~/" + FileName);

try{
    Response.ContentType = "text/xml";
    Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
    Response.TransmitFile(responseFile);
    Response.Flush();
}
finally {
    File.Delete(responseFile);
}

2013年1月7日 星期一

Google url shortener

Google url shortener 可以生產出短網止,也可生產出QR code

Get the MD5 code


private string HashString(string Value)
    {
        System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] data = System.Text.Encoding.ASCII.GetBytes(Value);
        data = x.ComputeHash(data);
        string ret = "";
        for (int i = 0; i < data.Length; i++)
            ret += data[i].ToString("x2").ToLower();
        return ret;
    }

2012年12月28日 星期五

window.location.Reload() and window.location.href=window.location.href; difference

window.location.Reload() is refresh page, it will submit the data again and has a alert message is continue.

window.location.href=window.location.href is redirect url.

2012年11月21日 星期三

Get screen width Javascript


<script type="text/javascript" language="javascript">
    if (document.getElementById("rightMenu") != null) {
        if (screen.width < 1200) {
            document.getElementById("rightMenu").style.display = "none";
        }
    }

</script>

position fixed for IE6

Add this code in the header

<!--[if IE 6]>
<style type="text/css">
.promomenu{
position:absolute; /* position fixed for IE6 */
top:expression(200+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');
right:expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');
}
</style>
<![endif]-->