2014年12月31日 星期三

ashx繼承方式

public class BaseHandler : IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        OnLoad(context);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
    public virtual void OnLoad(HttpContext context)
    { 
    }
}
 
================================
 
public class test : BaseHandler
    {
        public override void OnLoad(HttpContext context)
        {

           //DOSomething
        }
    } 

2014年12月15日 星期一

Javascript HTML Encode & Decode

function htmlEncode(value){
  //create a in-memory div, set it's inner text(which jQuery automatically encodes)
  //then grab the encoded contents back out.  The div never exists on the page.
  return $('<div/>').text(value).html();
}

function htmlDecode(value){
  return $('<div/>').html(value).text();
}

Javascript Replace All

取代所有 " 變成 _

'a"b"c'.replace(/"/g,"_");