日期:2014-05-18 浏览次数:21005 次
public static class JSHelper { public static void Alert(string pValue) { pValue = MyHelper.ToString(pValue); string _s = "alert('" + pValue + "');"; JSHelper.Execute(_s); } public static void Execute(string pKey, string pjsString) { string _jsString = MyHelper.ToString(pjsString); string _Key = MyHelper.ToString(pKey); Page _thisPage = (Page)HttpContext.Current.Handler; ScriptManager.RegisterStartupScript(_thisPage, _thisPage.GetType(), _Key, _jsString, true); } public static void Execute(string pjsString) { JSHelper.Execute(MyHelper.ToString(Guid.NewGuid()), pjsString); } public static void SetFocus(string pClientId) { pClientId = MyHelper.ToString(pClientId); MyHelper.Assert(pClientId != "", new ArgumentException("参数pClientId不允许为空")); string _s = "var _focus = document.getElementById('" + pClientId + "');"; _s += "if(_focus)_focus.focus();"; JSHelper.Execute(Guid.NewGuid().ToString(), _s); }