Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public static void Redirect(string url, string msg)
 {
     Ext.Redirect(url, msg, null);
 }
Exemplo n.º 3
0
 public static void Redirect(string url)
 {
     Ext.Redirect(url, null, null);
 }
Exemplo n.º 4
0
 internal virtual void SetHideHeaders(bool hide)
 {
     Ext.EnsureAjaxEvent();
     this.AddScript("{0}.getView().mainHd.setDisplayed({1});", this.ClientID, JSON.Serialize(!hide));
 }
Exemplo n.º 5
0
 public void RegisterColumnPlugins()
 {
     Ext.EnsureAjaxEvent();
     this.AddScript("{0}.initColumnPlugins({1}, true);", this.ClientID, this.GetColumnPlugins());
 }
Exemplo n.º 6
0
 public void AddKeyBinding(KeyBinding keyBinding)
 {
     Ext.EnsureAjaxEvent();
     this.AddScript("{0}.addBinding({1});", this.ClientID, JSON.Serialize(keyBinding));
 }
Exemplo n.º 7
0
 public void Update()
 {
     Ext.EnsureAjaxEvent();
     this.AddScript("{0}={1};", this.ClientID, JSON.Serialize(this.Items));
 }
Exemplo n.º 8
0
        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();
        }