/// <summary> /// 直接Response出刷新父页面脚本 /// </summary> public static void ResponseRefreshParentWindowScriptBlock() { ResponseRequireWindowCommandScriptBlock(); string script = DeluxeClientScriptManager.AddScriptTags("$HGRootNS.WindowCommand.openerExecuteCommand('refresh');"); HttpContext.Current.Response.Write(script); }
/// <summary> /// 直接Response出关闭窗口脚本,然后结束Response /// </summary> public static void ResponseCloseWindowScriptBlock() { ResponseRequireWindowCommandScriptBlock(); string script = DeluxeClientScriptManager.AddScriptTags("$HGRootNS.WindowCommand.executeCommand('close');"); HttpContext.Current.Response.Write(script); HttpContext.Current.Response.End(); }
private static void RequireWindowCommandScript() { RequiredScript(typeof(DeluxeScript)); string script = string.Format("$HGRootNS.WindowCommand.set_commandInputID('{0}');", DeluxeScript.C_CommandIputClientID); script = DeluxeClientScriptManager.AddScriptTags(script); Page page = GetCurrentPage(); page.ClientScript.RegisterStartupScript(page.GetType(), "RequireWindowCommandScript", script); }
/// <summary> /// 调整窗口大小和位置 /// </summary> /// <param name="windowFeature"></param> public static void AdjustWindow(IWindowFeature windowFeature) { RequiredScript(typeof(DeluxeScript)); string clintObject = WindowFeatureHelper.GetClientObject(windowFeature); string script = string.Format("$HGRootNS.WindowFeatureFunction.adjustWindow({0});", clintObject); Page page = GetCurrentPage(); DeluxeClientScriptManager.RegisterStartupScript(page, script); }
/// <summary> /// Response客户端弹出提示框 /// </summary> /// <param name="strMessage">提示框消息</param> /// <param name="strDetail">提示框详细信息</param> /// <param name="strTitle">提示框Title</param> public static void ResponseShowClientMessageScriptBlock(string strMessage, string strDetail, string strTitle) { ResponseClientMessageCommonScriptBlock(); string script = string.Format("$HGRootNS.ClientMsg.inform(\"{0}\", \"{1}\", \"{2}\");", CheckScriptString(strMessage), CheckScriptString(strDetail), CheckScriptString(strTitle)); script = DeluxeClientScriptManager.AddScriptTags(script); HttpContext.Current.Response.Write(script); }
private static void ResponseRequireWindowCommandScriptBlock() { StringBuilder strB = new StringBuilder(); strB.Append(GetRequiredScript(typeof(DeluxeScript))); strB.Append("\n"); string script = string.Format("$HGRootNS.WindowCommand.set_commandInputID('{0}');", DeluxeScript.C_CommandIputClientID); strB.Append(DeluxeClientScriptManager.AddScriptTags(script)); strB.Append("\n"); ResponseString(HttpContext.Current, RequireWindowCommandScriptKey, strB.ToString()); }
/// <summary> /// 注册响应OnLoad事件的脚本 /// </summary> /// <param name="page"></param> /// <param name="script"></param> public static void RegisterOnLoadScriptBlock(Page page, string script) { ScriptManager sm = ScriptManager.GetCurrent(page); if (sm != null) { DeluxeClientScriptManager.RegisterAjaxApplicationLoadScriptBlock(page, script); } else { DeluxeClientScriptManager.RegisterOnLoadScriptBlock(page, script); } }
/// <summary> /// 获取调整窗口大小和位置脚本 /// </summary> /// <param name="windowFeature"></param> /// <param name="addScriptTags"></param> /// <returns></returns> public static string ToAdjustWindowScriptBlock(this IWindowFeature windowFeature, bool addScriptTags) { string requireScript = WebUtility.GetRequiredScriptBlock(typeof(DeluxeScript)); string clintObject = WindowFeatureHelper.GetClientObject(windowFeature); //string callScript = string.Format("$HGRootNS.WindowFeatureFunction.adjustWindow({0});", clintObject); string callScript = string.Format("$HGRootNS.WindowFeatureFunction.registerAdjustWindow({0});", clintObject); string script = string.Format("{0}\n{1}", requireScript, callScript); if (addScriptTags) { script = DeluxeClientScriptManager.AddScriptTags(script); } return(script); }
/// <summary> /// Response客户端弹出错误框 /// </summary> /// <param name="strMessage">错误框消息</param> /// <param name="strDetail">错误框详细信息</param> /// <param name="strTitle">错误框Title</param> public static void ResponseShowClientErrorScriptBlock(string strMessage, string strDetail, string strTitle) { ResponseClientMessageCommonScriptBlock(); if (AllowResponseExceptionStackTrace() == false) { strDetail = string.Empty; } string script = string.Format("$HGRootNS.ClientMsg.stop(\"{0}\", \"{1}\", \"{2}\");", CheckScriptString(strMessage), CheckScriptString(strDetail), CheckScriptString(strTitle)); script = DeluxeClientScriptManager.AddScriptTags(script); WebApplicationExceptionExtension.TryWriteAppLog(strMessage, strDetail); HttpContext.Current.Response.Write(script); }
/// <summary> /// 向页面添加配置扩展信息 /// </summary> public static void LoadConfigPageContent(bool checkAutoLoad) { PageContentSection section = ConfigSectionFactory.GetPageExtensionSection(); Page page = GetCurrentPage(); if (checkAutoLoad) { if (!section.AutoLoad) { return; } if (page.Header == null) { return; } string headerAutoLoad = page.Header.Attributes["autoLoad"]; if (headerAutoLoad.IsNotEmpty() && headerAutoLoad.ToLower() == "false") { return; } } foreach (FilePathConfigElement cssElm in section.CssClasses) { string path = cssElm.Path; if (path != string.Empty) { ClientCssManager.RegisterHeaderEndCss(page, path); } } foreach (FilePathConfigElement scriptElm in section.Scripts) { string path = scriptElm.Path; if (path != string.Empty) { DeluxeClientScriptManager.RegisterHeaderEndScript(page, path); } } }
/// <summary> /// 得到某类型对应的脚本 /// </summary> /// <param name="scriptType">类型信息</param> /// <returns></returns> public static string GetRequiredScript(Type scriptType) { ExceptionHelper.FalseThrow <ArgumentNullException>(scriptType != null, "scriptType"); List <ResourceEntry> res = Script.ScriptObjectBuilder.GetScriptResourceEntries(scriptType); StringBuilder strB = new StringBuilder(1024); foreach (ResourceEntry re in res) { Page page = GetCurrentPage(); if (page == null) { page = new Page(); } string src = page.ClientScript.GetWebResourceUrl(re.ComponentType, re.ResourcePath); strB.Append(DeluxeClientScriptManager.GetScriptString(src)); strB.Append("\n"); } return(strB.ToString()); }
/// <summary> /// 向页面中增加与scriptType类型相关的脚本 /// </summary> /// <param name="scriptType">脚本相关类型</param> public static void RequiredScript(Type scriptType) { Page page = GetCurrentPage(); IEnumerable <ScriptReference> srs = Script.ScriptObjectBuilder.GetScriptReferences(scriptType); ScriptManager sm = ScriptManager.GetCurrent(page); foreach (ScriptReference sr in srs) { if (sm != null) { sm.Scripts.Add(sr); } else { DeluxeClientScriptManager.RegisterHeaderScript(page, page.ClientScript.GetWebResourceUrl(scriptType, sr.Name)); } } Script.ScriptObjectBuilder.RegisterCssReferences(GetCurrentPage(), scriptType); }