[CLOSED] How to update panel content during directevent

  1. #1

    [CLOSED] How to update panel content during directevent

    How can update this ListView during a DirectEvent?

    Bonus points: How can I make it update at some interval? Like every 5 minutes?

            <ext:Panel ID="NewsPanel" runat="server" Border="true" Title="News" Padding="5">
                <Content>
                    <asp:ListView ID="NewsList" runat="server">
                        <LayoutTemplate>
                            <ul>
                                <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                            </ul>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <li style="padding:3px">
                                <a href="#"><asp:Label ID="Headline" runat="server" Text='<%#Eval("Headline")%>' /></a>
                            </li>
                        </ItemTemplate>
                    </asp:ListView>
                </Content>
            </ext:Panel>
    Last edited by geoffrey.mcgill; Feb 04, 2015 at 3:10 AM. Reason: [CLOSED]
  2. #2
    I just figured it out. I just needed to call .Render() on the panel.
  3. #3
    There are several options depending on your requirements.

    1. Call .Render on the <ext:Panel>. This will re-render the entire Panel. The Panel will be destroyed and completely rebuilt. This creates some unnecessary overhead in your sample as it appears you're only interested in re-rendering the <asp:ListView>.

    2. Call .UpdateContent on the <ext:Panel>. This will not destroy the Panel object, but will re-render all of it's <Content> region. Good option if you want to update everything within the <Content> region, but not the best if you only want to update a specific control.

    3. Call .Update on the <asp:ListView>. This will only re-render the specific control on which it is called. If the control contains child controls, those will be re-rendered as well. This is probably the best option given your requirements above.

    BONUS POINTS: Use an <ext:TaskManager>.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <script runat="server">
        protected void Task1_Update(object sender, DirectEventArgs e)
        {
            this.ListView1.Update();
        }
    </script>
      
    <!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" />
            
            <ext:Panel runat="server" Border="true" Title="News" Padding="5">
                <Content>
                    <asp:ListView ID="ListView1" runat="server">
                        <LayoutTemplate>
                            <ul>
                                <asp:PlaceHolder runat="server" />
                            </ul>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <li style="padding:3px">
                                <a href="#"><asp:Label runat="server" Text="Headline" /></a>
                            </li>
                        </ItemTemplate>
                    </asp:ListView>
                </Content>
            </ext:Panel>
            <ext:TaskManager runat="server" AutoRunDelay="5000">
                <Tasks>
                    <ext:Task Interval="5000">
                        <DirectEvents>
                            <Update OnEvent="Task1_Update" />
                        </DirectEvents>
                    </ext:Task>
                </Tasks>
            </ext:TaskManager>
        </form>
      </body>
    </html>
    Last edited by geoffrey.mcgill; Oct 04, 2010 at 9:02 PM.
    Geoffrey McGill
    Founder
  4. #4
    More information on the <ext:TaskManager>, see

    https://examples1.ext.net/#/TaskManager/Basic/Overview/
    Geoffrey McGill
    Founder
  5. #5
    Here's a sample using .UpdateContent and UserControls, see

    https://examples1.ext.net/#/XRender/...UpdateContent/

    The .Update() Method can be called on any Control type object, including all non-Ext.NET Controls. This *should* re-render any Control from any other third party library or base ASP.NET Controls.

    Hope this helps.
    Geoffrey McGill
    Founder
  6. #6
    Extremely helpful. Thanks.
  7. #7
    Quote Originally Posted by geoffrey.mcgill View Post
    Here's a sample using .UpdateContent and UserControls, see

    https://examples1.ext.net/#/XRender/...UpdateContent/

    The .Update() Method can be called on any Control type object, including all non-Ext.NET Controls. This *should* re-render any Control from any other third party library or base ASP.NET Controls.

    Hope this helps.
    The .Update() method worked when I had it in my sample page, but when I databind the Listview when it is initially hidden, the panel renders, but the list is either not visible or not there. If I put in the .Render() method, it works in the page where it's initially hidden, but gets put in the upper left corner (overlapping other stuff) when it's in the other page where I'm using this user control.

    Any ideas what could be wrong? I'm trying to come up with a sample page to post, but it's proving to be pretty difficult.
  8. #8
    Hi,

    Listview when it is initially hidden
    How do you hide ListView? If you set Visible="false" then Update method won't work because none visible controls are not rendered but Update method requires that ASP.NET control is already rendered. You can try to rerender Ext.Net panel which contais asp:ListView

Similar Threads

  1. DirectEvent on Button - Content Not allowed?
    By Tbaseflug in forum 1.x Help
    Replies: 3
    Last Post: Jul 10, 2012, 8:29 PM
  2. Replies: 29
    Last Post: Feb 01, 2012, 4:58 PM
  3. Update Panel Content from Click
    By Rick Atkinson in forum 1.x Help
    Replies: 4
    Last Post: Oct 22, 2011, 6:48 AM
  4. Update Controls and Content during a DirectEvent
    By HosseinHelali in forum 1.x Help
    Replies: 1
    Last Post: Jul 12, 2011, 10:15 AM
  5. Replies: 0
    Last Post: Oct 19, 2010, 7:39 AM

Posting Permissions