[CLOSED] Msg.Confirm With DirectMethod Inside UserControl

  1. #1

    [CLOSED] Msg.Confirm With DirectMethod Inside UserControl

    Last edited by Baidaly; Jan 12, 2013 at 2:45 AM. Reason: [CLOSED]
  2. #2
    Hi...

    I use this and work Ok.. SVN 2.1

    ExtNet.Msg.Show(new MessageBoxConfig
                {
                    Title = "Avviso",
                    Message = "Delete this user: " + rowUte.UteUte + " ?",
                    Width = 300,
                    Buttons = MessageBox.Button.YESNO,
                    MessageBoxButtonsConfig = new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig
                        {
                            Text = "Si",
                            Handler = "Ext.net.DirectMethods.Delete()"
                        },
                        No = new MessageBoxButtonConfig
                        {
                            Text = "No"
                        }
                    },
                    Icon = MessageBox.Icon.QUESTION
                });
    
    
     [DirectMethod]
            public void Delete()
            {
                
            }
    But it's possible execute the test client side so as not to generate traffic to the server:

    Client side:

     <ext:Button ID="ButtonDelete" runat="server" Text="Cancella" Disabled="true" Scale="Medium"
                                                    IconUrl="Images/Icon/delete24.png" ToolTip="Cancella il cliente selezionato."
                                                    ToolTipType="Title">
                                            <Listeners>
                                                <Click Handler="DeleteCliente(#{GridPanelClienti}.getSelectionModel().getLastSelected(),
                                                    'Avviso',
                                                    'Delete Cliente: ' + #{GridPanelClienti}.getSelectionModel().getLastSelected().get('CliRagSoc') + ' ?')" />
                                            </Listeners>
                                        </ext:Button>
    
     <script type="text/javascript">
    
       var DeleteCliente = function (record, Title, Message) {
       
    if (condition)
     { 
        Ext.Msg.show({
            title: Title,
            msg: Message,
            buttons: { yes: "Si", no: "No" },
            icon: Ext.Msg.QUESTION,
            fn: function (btn) {
                if (btn == 'yes') {
                    Ext.net.DirectMethods.Delete(record.data.CliId);//send the id to delete
                }
            }
        });
     }
    };
           </script>
    Server side
    
     [DirectMethod]
            public void DeleteCliente(int pCliId)
            {
              
            }
    Thanks
    Aurelio
    Last edited by Aurelio; Jan 08, 2013 at 5:42 AM.
  3. #3
    Hi everybody,

    @Aurelio suggest a good thing. Really, if an action can be done client side, it is good to avoid an AJAX request.

    If you really need a server action, please provide a full test case (but simplified) to reproduce the problem (an ASPX and an ASCX).
  4. #4
    Hello,

    Aurelio thanks for the answer, but it still has the same error

    Uncaught TypeError: Can not call method 'Doyes' of undefined

     <script type="text/javascript">
    
         var confirmacion = function () {
    
             
                 Ext.Msg.show({
                     title: "Aviso",
                     msg: "Desea grabar los datos antes de cerrar la ventana?",
                     buttons: { yes: "Si", no: "No" },
                     icon: Ext.Msg.QUESTION,
                     fn: function (btn) {
                         if (btn == 'yes') {
                             Ext.net.DirectMethods.DoYes(); 
                         }
                     }
                 });
             
         };
           </script>
    
    <ext:Window runat="server" ID="WinFindCliente" AutoShow="false" Modal="true" Hidden="true"
        Width="700" Height="270" BodyPadding="5" Title="Bloqueo del Cliente">
        <Items>
            <ext:Panel ID="Panel1" runat="server" BodyStyle="background-color:#F8F8F8; padding:5px; border:dotted 1px gray;"
            Title="Datos del Cliente">
            </ext:Panel>
            <ext:Panel runat="server" BodyPadding="5">
                <Items><ext:TextArea ID="txtRazon" runat="server" Width="670" FieldLabel="Razon del Bloqueo" LabelAlign="Top" LabelStyle="font-weight:bold;"/>
                <ext:TextField runat="server" Visible="false" ID="txtDocumento"></ext:TextField>
                </Items>
                
                <Buttons>
                    <ext:Button ID="btnGrabar" runat="server" Text="Grabar" Icon="DatabaseSave">
                        <DirectEvents>
                            <Click OnEvent="BtnGrabarBloqueoClick"></Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnCancelar" runat="server" Text="Cerrar" Icon="Cancel">
                    <Listeners>
                        <Click Handler="confirmacion();" />
                    </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
            
        </Items>
    </ext:Window>
    in server side

    [DirectMethod]
            public void DoYes()
            {
                saveData();
                WinFindCliente.Hide();
            }

    Quote Originally Posted by Aurelio View Post
    Hi...

    I use this and work Ok.. SVN 2.1

    ExtNet.Msg.Show(new MessageBoxConfig
                {
                    Title = "Avviso",
                    Message = "Delete this user: " + rowUte.UteUte + " ?",
                    Width = 300,
                    Buttons = MessageBox.Button.YESNO,
                    MessageBoxButtonsConfig = new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig
                        {
                            Text = "Si",
                            Handler = "Ext.net.DirectMethods.Delete()"
                        },
                        No = new MessageBoxButtonConfig
                        {
                            Text = "No"
                        }
                    },
                    Icon = MessageBox.Icon.QUESTION
                });
    
    
     [DirectMethod]
            public void Delete()
            {
                
            }
    But it's possible execute the test client side so as not to generate traffic to the server:

    Client side:

     <ext:Button ID="ButtonDelete" runat="server" Text="Cancella" Disabled="true" Scale="Medium"
                                                    IconUrl="Images/Icon/delete24.png" ToolTip="Cancella il cliente selezionato."
                                                    ToolTipType="Title">
                                            <Listeners>
                                                <Click Handler="DeleteCliente(#{GridPanelClienti}.getSelectionModel().getLastSelected(),
                                                    'Avviso',
                                                    'Delete Cliente: ' + #{GridPanelClienti}.getSelectionModel().getLastSelected().get('CliRagSoc') + ' ?')" />
                                            </Listeners>
                                        </ext:Button>
    
     <script type="text/javascript">
    
       var DeleteCliente = function (record, Title, Message) {
       
    if (condition)
     { 
        Ext.Msg.show({
            title: Title,
            msg: Message,
            buttons: { yes: "Si", no: "No" },
            icon: Ext.Msg.QUESTION,
            fn: function (btn) {
                if (btn == 'yes') {
                    Ext.net.DirectMethods.Delete(record.data.CliId);//send the id to delete
                }
            }
        });
     }
    };
           </script>
    Server side
    
     [DirectMethod]
            public void DeleteCliente(int pCliId)
            {
              
            }
    Thanks
    Aurelio
  5. #5
    HI... jtorroledo

    In tne ResourceManager insert this:

    DirectMethodNamespace="Ext.net.DirectMethods"

     <ext:ResourceManager ID="ResourceManager1" runat="server" HideInDesign="True" Theme="Gray" DirectMethodNamespace="Ext.net.DirectMethods" />

    Sorry I forgot to enter the command DirectMethodNamespace="Ext.net.DirectMethods" in the ResourceManager

    It's work ok...

    If you have indicate: DirectMethodNamespace="YY" in this case the Javascript here:

     <script type="text/javascript">
    
            var confirmacion = function () {
    
    
                Ext.Msg.show({
                    title: "Aviso",
                    msg: "Desea grabar los datos antes de cerrar la ventana?",
                    buttons: { yes: "Si", no: "No" },
                    icon: Ext.Msg.QUESTION,
                    fn: function (btn) {
                        if (btn == 'yes') {
                            YY.DoYes();
                        }
                    }
                });
    
            };
           </script>
    It's work ok...

    I use the versione 2.1 of Ext.Net in the directory Branches
    Aurelio
    Last edited by Aurelio; Jan 09, 2013 at 1:13 AM.
  6. #6
    Please note that the default DirectMethodNamespace is "App.direct" in Ext.NET v2.
  7. #7
    Hi Daniil, Aurelio,

    My DirectMethodNamespace not working properly, I used the examples of Aurelio and not working, I have tried with a new project with NutGet ext.net downloading but I've the same error

    Click image for larger version. 

Name:	Error.PNG 
Views:	91 
Size:	41.7 KB 
ID:	5412.

    How I can validate if the installation of ext.net is successful?


    Thanks!!
    Quote Originally Posted by Daniil View Post
    Please note that the default DirectMethodNamespace is "App.direct" in Ext.NET v2.
  8. #8
    Please note that if DirectMethod inside user control then it will add additional namespace
    App.direct.ClientIDOfUserControl.MerthodName
    http://examples2.ext.net/#/Events/Di.../UserControls/

    You can set own alias (instead ClientID) or remove that alias via 'DirectMethodProxyID' attribute
    See the following sample
    http://examples2.ext.net/#/Events/Di...thods/ID_Mode/
    Vladimir Shcheglov
    Sr. Developer
  9. #9
    Thanks!! it works well.

Similar Threads

  1. Replies: 4
    Last Post: Dec 19, 2012, 10:58 AM
  2. Replies: 8
    Last Post: Feb 15, 2012, 10:04 AM
  3. Replies: 1
    Last Post: Mar 08, 2011, 7:48 PM
  4. [CLOSED] DirectMethod and UserControl
    By jmcantrell in forum 1.x Premium Help
    Replies: 4
    Last Post: Jun 21, 2010, 8:15 PM
  5. Replies: 4
    Last Post: Feb 25, 2010, 10:33 AM

Tags for this Thread

Posting Permissions