[CLOSED] Problem with DirectMethods and Different instances of controls while in Release mode

  1. #1

    [CLOSED] Problem with DirectMethods and Different instances of controls while in Release mode

    Hi again!

    I'm having troubles when compiling in release mode.

    I'll explain the situation first.

    I have a user control containing a grid, the user control configures the grid to display different commands on it. One of those commands is the "Delete" command.

    Whenever the user presses "Delete" it shows a confirmation window's.The confirm button calls a direct method.

    The problem that i'm having is that if i have more than one control in the page, whenever i confirm in any window, the directmethod from the last usercontrol gets called. This only happens in RELEASE mode in DEBUG it works OK.

    This is the code that executes the confirmation:

     if (command == "Delete" && CommandDeleteRequiresConfirmation)
                    {
                        result.RequiresConfirmation = true;
                        result.ConfirmationMessage = "¿Desea eliminar el registro seleccionado?";
                        result.ConfirmationTitle = "Confirmación de eliminación";
                        result.ConfirmationSuccessMethodName = this.ClientID + ".Grid" + command + "Command";
    
                        Telefe.Framework.Logging.Logger.DebugFormat("{0} - Confirmed {2} will call: {1}", this.ID, result.ConfirmationSuccessMethodName, command);
                    }
                    else if (command == "Edit" && CommandEditRequiresConfirmation)
                    {
                        result.RequiresConfirmation = true;
                        result.ConfirmationMessage = "¿Desea editar el registro seleccionado?";
                        result.ConfirmationTitle = "Confirmación de edicion";
                        result.ConfirmationSuccessMethodName = this.ClientID + ".Grid" + command + "Command";
                        Telefe.Framework.Logging.Logger.DebugFormat("{0} - Confirmed {2} will call: {1}", this.ID, result.ConfirmationSuccessMethodName, command);
                    }
                    else if (command == "Clone" && CommandCloneRequiresConfirmation)
                    {
                        result.RequiresConfirmation = true;
                        result.ConfirmationMessage = "¿Desea clonar el registro seleccionado?";
                        result.ConfirmationTitle = "Confirmación de clonacion";
                        result.ConfirmationSuccessMethodName = this.ClientID + ".Grid" + command + "Command";
                        Telefe.Framework.Logging.Logger.DebugFormat("{0} - Confirmed {2} will call: {1}", this.ID, result.ConfirmationSuccessMethodName, command);
                    }
    And then i show the confirmation window:
                if (result.RequiresConfirmation)
                {
                    var method = string.Format("Ext.net.DirectMethods.{0}({1})",result.ConfirmationSuccessMethodName, id);
                    var messageBoxButtonConfig = new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig { Handler = method, Text = "Si", },
                        No = new MessageBoxButtonConfig { Handler = "", Text = "No", }
                    };
    
                    X.Msg.Confirm(result.ConfirmationTitle, result.ConfirmationMessage, messageBoxButtonConfig).Show();
                }
    And this is the code of the direct method:

            /// <summary>
            /// This command executes when the user confirms a Delete command 
            /// </summary>
            /// <param name="id">The id of the row to delete</param>
            [DirectMethod]
            public virtual void GridDeleteCommand(long id)
            {
                Telefe.Framework.Logging.Logger.DebugFormat("{0} - GridDeleteCommand ({1}): {3} - {2} ", this.ID, id, CommandDeleteAction, _commandDeleteActionName);
            }
    This is the output of the rendered js:
    ctl00_ContentPlaceHolder1_grdEmisionesCaidas: {
                GridCreateCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridCreateCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridCloneCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridCloneCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridDeleteCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridDeleteCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridEditCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridEditCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                OnRefresh: function (e, config) {
                    Ext.net.DirectMethod.request("OnRefresh", Ext.applyIf(config || {}, {
                        params: {
                            e: e
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                RaiseWindowClosed: function (config) {
                    Ext.net.DirectMethod.request("RaiseWindowClosed", Ext.applyIf(config || {}, {
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                }
            },
            ctl00_ContentPlaceHolder1_grdTotalesPrograma: {
                GridCreateCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridCreateCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridCloneCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridCloneCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridDeleteCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridDeleteCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                GridEditCommand: function (id, config) {
                    Ext.net.DirectMethod.request("GridEditCommand", Ext.applyIf(config || {}, {
                        params: {
                            id: id
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                OnRefresh: function (e, config) {
                    Ext.net.DirectMethod.request("OnRefresh", Ext.applyIf(config || {}, {
                        params: {
                            e: e
                        },
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                },
                RaiseWindowClosed: function (config) {
                    Ext.net.DirectMethod.request("RaiseWindowClosed", Ext.applyIf(config || {}, {
                        control: "ctl00_ContentPlaceHolder1_grdTotalesPrograma"
                    }));
                }
            }
    Is this a bug of the ext.net or what's is causing this different behaviour between the Release mode and the Debug one?


    Thanks!
    Last edited by Daniil; Apr 19, 2012 at 7:37 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, rendered JavaScript doesn't look correct.

    Though I am unable to reproduce the problem using the sample below. Please provide your test sample.

    Example Page
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <%@ Register Src="~/TestUC.ascx" TagPrefix="uc" TagName="TestUC" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <uc:TestUC ID="TestUC1" runat="server" />
            <uc:TestUC ID="TestUC2" runat="server" />
        </form>
    </body>
    </html>
    Example User Control
    <%@ Control Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void TestDirectMethod()
        {
            X.Msg.Alert("", string.Format("I am {0}.", this.ClientID)).Show();
        }
    </script>
    
    <ext:Button runat="server" Text="Click me">
        <Listeners>
            <Click Handler="#{DirectMethods}.TestDirectMethod();" />
        </Listeners>
    </ext:Button>
  3. #3
    I am having the exactly same problem.

    My bug only occurs in release mode, and the directmethod only gets the value of the last usercontrol.

    My thread is on the first page also.

    forums.ext.net/showthread.php?18395-ListView-with-HtmlEditor-gt-HtmlEditor-value-is-null
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi,

    Yes, rendered JavaScript doesn't look correct.

    Though I am unable to reproduce the problem using the sample below. Please provide your test sample.
    Ok, i'm working on creating a smaller page with this problem... but our grid has too many functionalities, it's difficult to "simplify" it

    Quote Originally Posted by SouthDeveloper View Post
    I am having the exactly same problem.

    My bug only occurs in release mode, and the directmethod only gets the value of the last usercontrol.

    My thread is on the first page also.

    forums.ext.net/showthread.php?18395-ListView-with-HtmlEditor-gt-HtmlEditor-value-is-null
    yes, it seems to be the same problem
  5. #5
    Please update from SVN and retest, the issue should be fixed
  6. #6
    Thanks!!, Solved!! =)

Similar Threads

  1. [CLOSED] DirectMethods in custom controls
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 11, 2012, 2:10 PM
  2. DirectMethods Problem
    By aelen in forum 1.x Help
    Replies: 3
    Last Post: Dec 26, 2011, 5:34 AM
  3. Replies: 11
    Last Post: May 23, 2011, 1:33 PM
  4. Replies: 2
    Last Post: Feb 16, 2011, 9:10 AM
  5. View controls internal in mode design
    By olimpia in forum 1.x Help
    Replies: 4
    Last Post: Jun 09, 2009, 8:12 AM

Posting Permissions