void Application_Error(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; HttpContext context = app.Context; if (Ext.HasXCooliteHeader(context.Request)) { AjaxResponse responseObject = new AjaxResponse(true); string error = null; if (HttpContext.Current != null) { error = HttpContext.Current.Error != null?HttpContext.Current.Error.ToString() : null; } if (!ScriptManager.AjaxSuccess || !string.IsNullOrEmpty(error)) { responseObject.Success = false; if (!string.IsNullOrEmpty(error)) { responseObject.ErrorMessage = error; } else { responseObject.ErrorMessage = ScriptManager.AjaxErrorMessage; } } app.Context.Response.Clear(); app.Context.Response.ClearContent(); app.Context.Response.ClearHeaders(); app.Context.Response.StatusCode = (int)HttpStatusCode.OK; app.Context.Response.Write(responseObject.ToString()); app.Context.Response.End(); app.CompleteRequest(); } }
public static void Redirect(string url, string msg) { Ext.Redirect(url, msg, null); }
public static void Redirect(string url) { Ext.Redirect(url, null, null); }
internal virtual void SetHideHeaders(bool hide) { Ext.EnsureAjaxEvent(); this.AddScript("{0}.getView().mainHd.setDisplayed({1});", this.ClientID, JSON.Serialize(!hide)); }
public void RegisterColumnPlugins() { Ext.EnsureAjaxEvent(); this.AddScript("{0}.initColumnPlugins({1}, true);", this.ClientID, this.GetColumnPlugins()); }
public void AddKeyBinding(KeyBinding keyBinding) { Ext.EnsureAjaxEvent(); this.AddScript("{0}.addBinding({1});", this.ClientID, JSON.Serialize(keyBinding)); }
public void Update() { Ext.EnsureAjaxEvent(); this.AddScript("{0}={1};", this.ClientID, JSON.Serialize(this.Items)); }
public override void Flush() { if (this.html.ToString().StartsWith("<Coolite.ManualAjaxResponse>")) { string script = StringUtils.LeftOf(StringUtils.RightOf(this.html.ToString(), "<Coolite.ManualAjaxResponse>"), "</Coolite.ManualAjaxResponse>"); byte[] rsp = System.Text.Encoding.UTF8.GetBytes(script); this.response.Write(rsp, 0, rsp.Length); this.response.Flush(); return; } AjaxResponse ajaxResponse = new AjaxResponse(true); HttpContext context = HttpContext.Current; string error = context == null ? null : (context.Error != null ? context.Error.ToString() : null); if (!ScriptManager.AjaxSuccess || !string.IsNullOrEmpty(error)) { ajaxResponse.Success = false; if (!string.IsNullOrEmpty(error)) { ajaxResponse.ErrorMessage = error; } else { ajaxResponse.ErrorMessage = ScriptManager.AjaxErrorMessage; } } else { if (ScriptManager.ReturnViewState) { ajaxResponse.ViewState = AjaxRequestFilter.GetHiddenInputValue(this.html.ToString(), VIEWSTATE); ajaxResponse.ViewStateEncrypted = AjaxRequestFilter.GetHiddenInputValue(this.html.ToString(), VIEWSTATEENCRYPTED); ajaxResponse.EventValidation = AjaxRequestFilter.GetHiddenInputValue(this.html.ToString(), EVENTVALIDATION); } object o = ScriptManager.ServiceResponse; if (o is Response) { ajaxResponse.ServiceResponse = new ClientConfig().Serialize(o); } else { ajaxResponse.ServiceResponse = o != null?JSON.Serialize(o) : null; } if (ScriptManager.ExtraParamsResponse.Count > 0) { ajaxResponse.ExtraParamsResponse = ScriptManager.ExtraParamsResponse.ToJson(); } if (ScriptManager.AjaxMethodResult != null) { ajaxResponse.Result = ScriptManager.AjaxMethodResult; } string script = StringUtils.LeftOf(StringUtils.RightOf(this.html.ToString(), "<Coolite.AjaxResponse>"), "</Coolite.AjaxResponse>"); if (!string.IsNullOrEmpty(script)) { ajaxResponse.Script = string.Concat("<string>", script); } } bool isUpload = context != null && Ext.HasInputFieldMarker(context.Request); byte[] data = System.Text.Encoding.UTF8.GetBytes((isUpload ? "<textarea>":"") + ajaxResponse.ToString() + (isUpload ? "</textarea>":"")); this.response.Write(data, 0, data.Length); this.response.Flush(); }