Beispiel #1
0
        public static void HandleClientAPICallbackEvent(Page objPage, ClientAPICallBackResponse.CallBackTypeCode eType)
        {
            if (IsInCallback(objPage))
            {
                if (eType != ClientAPICallBackResponse.CallBackTypeCode.ProcessPage)
                {
                    string[] arrIDs = objPage.Request[SCRIPT_CALLBACKID].Split(Convert.ToChar(" "));
                    string strControlID = arrIDs[0];
                    string strClientID = "";
                    if (arrIDs.Length > 1)
                    {
                        strClientID = arrIDs[1];
                    }

                    string strParam = objPage.Server.UrlDecode(objPage.Request[SCRIPT_CALLBACKPARAM]);
                    Control objControl = null;
                    IClientAPICallbackEventHandler objInterface = null;
                    ClientAPICallBackResponse objResponse = new ClientAPICallBackResponse(objPage, ClientAPICallBackResponse.CallBackTypeCode.Simple);

                    try
                    {
                        objPage.Response.Clear(); //clear response stream
                        if (strControlID == SCRIPT_CALLBACKPAGEID)
                        {
                            objControl = objPage;
                        }
                        else
                        {
                            objControl = Globals.FindControlRecursive(objPage, strControlID, strClientID);
                        }
                        if (objControl != null)
                        {
                            if ((objControl) is HtmlForm) //form doesn't implement interface, so use page instead
                            {
                                objInterface = (IClientAPICallbackEventHandler)objPage;
                            }
                            else
                            {
                                objInterface = (IClientAPICallbackEventHandler)objControl;
                            }

                            if (objInterface != null)
                            {
                                try
                                {
                                    objResponse.Response = objInterface.RaiseClientAPICallbackEvent(strParam);
                                    objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.OK;
                                }
                                catch (Exception ex)
                                {
                                    objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.GenericFailure;
                                    objResponse.StatusDesc = ex.Message;
                                }
                            }
                            else
                            {
                                objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.InterfaceNotSupported;
                                objResponse.StatusDesc = "Interface Not Supported";
                            }
                        }
                        else
                        {
                            objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.ControlNotFound;
                            objResponse.StatusDesc = "Control Not Found";
                        }
                    }
                    catch (Exception ex)
                    {
                        objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.GenericFailure;
                        objResponse.StatusDesc = ex.Message;
                    }
                    finally
                    {
                        objResponse.Write();
                        //objPage.Response.Flush()
                        objPage.Response.End();
                    }
                }
                else
                {
                    objPage.SetRenderMethodDelegate(new RenderMethod(CallbackRenderMethod));
                }
            }
        }
Beispiel #2
0
 public static string GetCallbackEventReference(Control objControl, string strArgument, string strClientCallBack, string strContext, string srtClientErrorCallBack, string strClientStatusCallBack, ClientAPICallBackResponse.CallBackTypeCode eCallbackType)
 {
     return GetCallbackEventReference(objControl, strArgument, strClientCallBack, strContext, srtClientErrorCallBack, strClientStatusCallBack, null, eCallbackType);
 }
Beispiel #3
0
        public static string GetCallbackEventReference(Control objControl, string strArgument, string strClientCallBack, string strContext, string srtClientErrorCallBack, string strClientStatusCallBack, string strPostChildrenOfId, ClientAPICallBackResponse.CallBackTypeCode eCallbackType)
        {
            string strCallbackType = Convert.ToInt32(eCallbackType).ToString();
            if (strArgument == null)
            {
                strArgument = "null";
            }
            if (strContext == null)
            {
                strContext = "null";
            }
            if (srtClientErrorCallBack == null)
            {
                srtClientErrorCallBack = "null";
            }
            if (strClientStatusCallBack == null)
            {
                strClientStatusCallBack = "null";
            }
            // HACK : Modified to not error if object is null.
            //if (strPostChildrenOfId.Length == 0)
            if (String.IsNullOrEmpty(strPostChildrenOfId))
            {
                strPostChildrenOfId = "null";
            }
            else if (strPostChildrenOfId.StartsWith("'") == false)
            {
                strPostChildrenOfId = "'" + strPostChildrenOfId + "'";
            }
            string strControlID = objControl.ID;
            if (BrowserSupportsFunctionality(ClientFunctionality.XMLHTTP) && BrowserSupportsFunctionality(ClientFunctionality.XML))
            {
                RegisterClientReference(objControl.Page, ClientNamespaceReferences.dnn_xml);
                RegisterClientReference(objControl.Page, ClientNamespaceReferences.dnn_xmlhttp);

                if ((objControl) is Page && strControlID.Length == 0) //page doesn't usually have an ID so we need to make one up
                {
                    strControlID = SCRIPT_CALLBACKPAGEID;
                }

                if ((objControl) is Page == false)
                {
                    strControlID = strControlID + " " + objControl.ClientID; //ID is not unique (obviously)
                }

                return string.Format("dnn.xmlhttp.doCallBack('{0}',{1},{2},{3},{4},{5},{6},{7},{8});", strControlID, strArgument, strClientCallBack, strContext, srtClientErrorCallBack, strClientStatusCallBack, "null", strPostChildrenOfId, strCallbackType);
            }
            else
            {
                return "";
            }
        }
Beispiel #4
0
        public static void HandleClientAPICallbackEvent(Page objPage, ClientAPICallBackResponse.CallBackTypeCode eType)
        {
            if (IsInCallback(objPage))
            {
                if (eType != ClientAPICallBackResponse.CallBackTypeCode.ProcessPage)
                {
                    string[] arrIDs       = objPage.Request[SCRIPT_CALLBACKID].Split(Convert.ToChar(" "));
                    string   strControlID = arrIDs[0];
                    string   strClientID  = "";
                    if (arrIDs.Length > 1)
                    {
                        strClientID = arrIDs[1];
                    }

                    string  strParam   = objPage.Server.UrlDecode(objPage.Request[SCRIPT_CALLBACKPARAM]);
                    Control objControl = null;
                    IClientAPICallbackEventHandler objInterface = null;
                    ClientAPICallBackResponse      objResponse  = new ClientAPICallBackResponse(objPage, ClientAPICallBackResponse.CallBackTypeCode.Simple);

                    try
                    {
                        objPage.Response.Clear(); //clear response stream
                        if (strControlID == SCRIPT_CALLBACKPAGEID)
                        {
                            objControl = objPage;
                        }
                        else
                        {
                            objControl = Globals.FindControlRecursive(objPage, strControlID, strClientID);
                        }
                        if (objControl != null)
                        {
                            if ((objControl) is HtmlForm) //form doesn't implement interface, so use page instead
                            {
                                objInterface = (IClientAPICallbackEventHandler)objPage;
                            }
                            else
                            {
                                objInterface = (IClientAPICallbackEventHandler)objControl;
                            }

                            if (objInterface != null)
                            {
                                try
                                {
                                    objResponse.Response   = objInterface.RaiseClientAPICallbackEvent(strParam);
                                    objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.OK;
                                }
                                catch (Exception ex)
                                {
                                    objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.GenericFailure;
                                    objResponse.StatusDesc = ex.Message;
                                }
                            }
                            else
                            {
                                objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.InterfaceNotSupported;
                                objResponse.StatusDesc = "Interface Not Supported";
                            }
                        }
                        else
                        {
                            objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.ControlNotFound;
                            objResponse.StatusDesc = "Control Not Found";
                        }
                    }
                    catch (Exception ex)
                    {
                        objResponse.StatusCode = ClientAPICallBackResponse.CallBackResponseStatusCode.GenericFailure;
                        objResponse.StatusDesc = ex.Message;
                    }
                    finally
                    {
                        objResponse.Write();
                        //objPage.Response.Flush()
                        objPage.Response.End();
                    }
                }
                else
                {
                    objPage.SetRenderMethodDelegate(new RenderMethod(CallbackRenderMethod));
                }
            }
        }