[CLOSED] Reload Clild Iframe after delete item.

  1. #1

    [CLOSED] Reload Clild Iframe after delete item.

    Hi guys,

    I have an Problem. After delete an item of the list I can not reload the page.

    Please, look below my example:

    Parent:

    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script runat="server">
            
            [DirectMethod]
            public void Mensagem(string icone, string titulo, string mensagem)
            {
                if (icone.Equals("Info") || icone.Equals("Sucesso"))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title = titulo,
                        Message = mensagem,
                        Buttons = MessageBox.Button.OK,
                        Icon = MessageBox.Icon.INFO
                    });
                }
            }
            
            protected void ButtonTeste_Clique(object sender, DirectEventArgs e)
            {            
                PanelComentario.LoadContent(new LoadConfig("Child.aspx")
                {
                    Mode = LoadMode.IFrame,
                    Scripts = true,
                    MaskMsg = "Aguarde...",
                    ShowMask = true,
                    NoCache = true
                });
            }
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
    
        <ext:ResourceManager ID="ResourceManagerComentarioLista" runat="server" DisableViewState="true" Theme="Gray">            
        </ext:ResourceManager>
    
        <ext:Panel runat="server" ID="teste">
            <Items>
                
                <ext:Panel ID="PanelComentario" runat="server"  Border="false" Title="Comentário" IconCls="Comentario" Height="300" Width="290" Padding="10" AutoScroll="true">     
                                                                                                
                </ext:Panel>
                
                <ext:Button runat="server" ID="ButtonTeste" Text="Load Iframe">
                    <DirectEvents>
                        <Click OnEvent="ButtonTeste_Clique">
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>

    Child:

    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!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 id="Head1" runat="server">
        <title></title>
        <style type="text/css">   
            #BOXPostIt  {clear:right;position:relative;width:235px;height:100px;float:right;left:-2px;top:-15px;margin:5px 3px 0px 0px;background-image:url("../Resources/images/bg/bgdicas.gif");}
            #BOXPostIt_pq {clear:right;position:relative;width:125px;height:130px;float:right;left:-2px;top:-15px;margin:5px 3px 0px 0px;background-image:url("../Resources/images/bg/bgdicas.gif");}
            #BOXPostItcontainer {clear:right;position:relative;float:left;top:13px;left:12px;}
            #BOXPostIt01 {clear:right;position:relative;width:235px;height:100px;float:right;left:-151px;margin:5px 3px 0px 0px;background-image:url("../Resources/images/bg/bgdicas.gif");}
            #BOXPostItcontainer01   {clear:right;position:relative;float:left;top:13px;left:12px;}
            .BOXPostItTit {font-size:14px;font-weight:bold;color:#FF6600; margin:10px;}
            .BOXPostItText  {clear:both;font-size:11px;font-family:Arial, Verdana, Helvetica;}
    
            .BOXPostItlnk:link {text-decoration:none;color:#003399;font-size:11px;font-weight:bold;font-family:Arial, Verdana, Helvetica;text-align:right;padding:10px;width:190px;}
            .BOXPostItlnk:visited {text-decoration:none;color:#003399;font-size:11px;font-weight:bold;font-family:Arial, Verdana, Helvetica;}
            .BOXPostItlnk:hover  {text-decoration:underline;color:#ff6600;font-size:11px;font-weight:bold;font-family:Arial, Verdana, Helvetica;}
            .BOXPostItlnk:active  {text-decoration:none;color:#003399;font-size:11px;font-weight:bold;font-family:Arial, Verdana, Helvetica}       
            
            .excluir{ background-image:url("../Resources/icons/cross.png"); overflow: hidden}  
            .editar{ background-image:url("../Resources/icons/page_white_edit.png"); overflow: hidden}  
        </style> 
        <script type="text/javascript">
            var excluir = function (id) {
                Ext.net.DirectMethods.Confirma(id);
            }
        </script>
            <script runat="server">
                
                System.Collections.Generic.List<nota> notas;
                
                public class nota
                {
                    public int id { get; set; }
                    public string nome { get; set; }
                    public DateTime data { get; set; }
                    public string conteudo { get; set; }            
                }
                protected void Page_Load(object sender, EventArgs e)
                {
    
                        notas = new System.Collections.Generic.List<nota>()
                        {
                            new nota{id=1, nome="Nome1", conteudo="Conteudo1", data= DateTime.Now},
                            new nota{id=2, nome="Nome2", conteudo="Conteudo2", data= DateTime.Now},
                            new nota{id=3, nome="Nome3", conteudo="Conteudo3", data= DateTime.Now},
                            new nota{id=4, nome="Nome4", conteudo="Conteudo4", data= DateTime.Now}
                        };
                        this.ObjHolderComentario.Items.Add("notas", notas);
                }
                
                [DirectMethod]
                public void Excluir_Clique(int notaID)
                {
                    if (notaID > 0)
                    {
                        try
                        {
                            nota nota = notas.Find(a => a.id == notaID);
    
                            bool apagou = notas.Remove(nota);
                            if (apagou)
                            {
                                X.Js.Call("parent.Ext.net.DirectMethods.Mensagem", "Info", "Atenção", "Comentário excluído com sucesso!");                            
                            }
                            else
                            {
                                X.Js.Call("parent.Ext.net.DirectMethods.Mensagem", "Erro", "Erro", "O comentário não pôde ser excluído!");
                            }
                        }
                        catch (Exception)
                        {
                            X.Js.Call("parent.Ext.net.DirectMethods.Mensagem", "Erro", "Erro", "O comentário não pôde ser excluído!");
                        }
                    }
                }
    
                [DirectMethod]
                public void Confirma(int notaID)
                {
                    X.Msg.Confirm("Atenção", "Deseja excluir?", new MessageBoxButtonsConfig
                    {
                        Yes = new MessageBoxButtonConfig
                        {
                            Handler = "Ext.net.DirectMethods.Excluir_Clique(" + notaID + ")",
                            Text = "Sim"
                        },
                        No = new MessageBoxButtonConfig
                        {
                            Handler = "return;",
                            Text = "Não"
                        }
                    }).Show();
                }
            </script>
    
    
    </head>
    <body>
        <form id="form1" runat="server">
    
            <ext:ResourceManager ID="ResourceManagerComentarioLista" runat="server" DisableViewState="true" Theme="Gray">            
            </ext:ResourceManager>
    
            <ext:ObjectHolder ID="ObjHolderComentario" runat="server" />
    
            <ext:XTemplate ID="TplComentario" runat="server" >                
                    <Html>
                        <tpl for=".">
                               <div id="BOXPostIt">
                                     <div id="BOXPostItcontainer">
                                            <table width="215"  border="0" cellspacing="0" cellpadding="0">                                             
                                                   <tr>                                                    
                                                          <td class="BOXPostItText">
                                                                 {nome}   
                                                                  <br />
                                                                {data}
                                                                <br />
                                                                {conteudo}
                                                          </td>
                                                   </tr>
                                                   <tr align="right">
                                                          <td align="right" style="padding:1px;">                                                           
                                                                <button type='button' alt='Excluir'  class='excluir' onClick='excluir({id})'></button>                                                            
                                                          </td>
                                                   </tr>
                                            </table>
                                     </div>
                               </div>                          
                        </tpl>     
                    </Html>
            </ext:XTemplate>  
            
             <ext:Panel ID="Panel1" runat="server" Border="false" Padding="10">
                <Listeners>
                        <Render Handler= "#{TplComentario}.overwrite(this.body, #{ObjHolderComentario}.notas);" />
                </Listeners>
                <LoadMask Msg="Carregando..." ShowMask="true"  />
            </ext:Panel>     
        </form>
    </body>
    </html>
    You can run this example.

    Any suggestion?

    Thanks in advance.
    Last edited by Daniil; Oct 23, 2011 at 5:19 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Quote Originally Posted by stoque View Post
    After delete an item of the list I can not reload the page.
    Please provide more details what you mean under "I can not reload the page".
  3. #3
    When I delete an item, I need to reload the page.
    I did so:
    Painel.reload();
    But did not work.
  4. #4
    Please clarify what does "But did not work. " mean?

    Are you expecting an item should be removed after reloading?

    Well, when you reload a page a hard reloading occurs and a common page lify cycle is executed.

    It means that the Page_Load handler is executed as well and all items are restored.

    After removing a note you should update the ObjHolderComentario and call
    #{TplComentario}.overwrite(this.body, #{ObjHolderComentario}.notas);
    again.
  5. #5
    Please clarify what does "But did not work. " mean?
    All items remain on screen.

    After removing a note you should update the ObjHolderComentario and call
    1
    #{TplComentario}.overwrite(this.body, #{ObjHolderComentario}.notas);
    I had already done so, but the items remain.

    Well, when you reload a page a hard reloading occurs and a common page lify cycle is executed.

    It means that the Page_Load handler is executed as well and all items are restored.
    Yes, but I reload the list from the database. That was just so you can run on your machine.

    Obs.: It doesn't happen error and exception.

    You could run in your machine?

    Any suggestion?

    Thanks for your helper.
  6. #6
    Thanks for the details.

    Quote Originally Posted by stoque View Post
    You could run in your machine?
    The example you posted? Well, repeat myself I see the example should not work and my recommendations are in the that post;
    http://forums.ext.net/showthread.php...ll=1#post67297
    Yes, but I reload the list from the database.
    Understand. So, the example you posted doesn't demonstrate the real situation.

    Where do you call Panel.reload()?

    Please provide a sample which would reproduce the real problem.

    You don't need to use database, you could save a list, for example, in a Session.
  7. #7
    Hi Daniil,

    I was not calling this method:
     this.ObjHolderComentario.UpdateData();
    After call this method I call the render of the panel, again.
    Panel1.Render();
    Because there is already a listener to render.
    <Listeners>
                        <Render Handler= "#{TplComentario}.overwrite(this.body, #{ObjHolderComentario}.notas);" />
                </Listeners>
    Please, mark as solved.

    Thanks for your help.

    The world cup is ours! Brazil!
  8. #8
    Thanks for the update. It can help someone in the future.

Similar Threads

  1. [CLOSED] Delete selected Item from PropertyGrid
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 21, 2011, 10:41 PM
  2. [CLOSED] Delete item GridPanel
    By stoque in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 07, 2011, 6:01 PM
  3. [CLOSED] dataview delete item(s)
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 01, 2011, 1:46 PM
  4. Force reload on IFrame
    By Born2Code in forum 1.x Help
    Replies: 2
    Last Post: Mar 22, 2010, 5:25 AM
  5. [CLOSED] Reload an iframe within a panel
    By jeremyl in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 05, 2009, 12:55 PM

Tags for this Thread

Posting Permissions