[CLOSED] XScript - GridView inside a Panet-Content in a ListView

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] XScript - GridView inside a Panet-Content in a ListView

    Hi,

    Whenever I have an asp gridview inside a Panel-Content in a ListView my XScript dont work anymore.

    Bellow is a sample code.

    If you uncomment the gridview line, the window wont open anymore. I checked the scripts generated with XScript and they change.

    Thanks.

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var dt = new DataTable();
                dt.Columns.Add("Column1");
                dt.Columns.Add("Column2");
                var dr = dt.NewRow();
                var dr2 = dt.NewRow();
    
                dt.Rows.Add(dr);
                dt.Rows.Add(dr2);
                ListViewGrid.DataSource = dt;
                ListViewGrid.DataBind();
    
    
            }
        }
    
        protected void ListViewList_ItemDataBound(object sender, ListViewItemEventArgs eventArgs)
        {
            var panel = eventArgs.Item.FindControl("Panel1") as Ext.Net.Panel;
            panel.ID = "p" + TabPanel1.Items.Count;
            TabPanel1.Items.Add(panel);
        }
    
    
    </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>Simple Array Grid - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        <ext:ResourcePlaceHolder runat="server" />
        <ext:XScript runat="server">
        <script type="text/javascript">
        function id() 
        {
            #{Label1};
            #{Window1}.getId();
        }
        </script>
        </ext:XScript>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Label ID="Label1" runat="server" />
        <ext:TabPanel ID="TabPanel1" runat="server">
        </ext:TabPanel>
        <asp:ListView OnItemDataBound="ListViewList_ItemDataBound" ID="ListViewGrid" runat="server">
            <ItemTemplate>
                <ext:Panel ID="Panel1" runat="server" Title='1'>
                    <Content>
                    1
                        <%--<asp:GridView ID="GridViewEdital3" runat="server" />--%>
                    </Content>
                </ext:Panel>
                <ext:Button Text="Open Window" runat="server">
                    <Listeners>
                        <Click Handler="#{Window1}.show();" />
                    </Listeners>
                </ext:Button>
            </ItemTemplate>
        </asp:ListView>
        <ext:Window Hidden="true" runat="server" ID="Window1">
            <Items>
                <ext:Label Text="1" runat="server" />
            </Items>
        </ext:Window>
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 15, 2011 at 8:10 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I don't know what way <ext:Script> can break your code.

    Need to test it, but when I run the sample you posted, I'm getting the exception. Is it runnable?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I don't know what way <ext:Script> can break your code.

    Need to test it, but when I run the sample you posted, I'm getting the exception. Is it runnable?
    It is runnable. I will show you what happens to XScript:

    If gridview is commented:
        <script type="text/javascript">     
            function id()    
            {         
                 Label1;         
                 Window1.getId();     
             }     
           </script>
    If gridiview is uncommented:
        <script type="text/javascript">     
         function id()     
         {         
             Label1;         
             Ext.get("Window1").getId();     
          }     
         </script>
    In a large page, where the Window id changes to ctl00_00_00_Window1, in the second scenario, it still does a Ext.get("Window1").getId(), instead of ctl00_00_00_Window1.getId().
  4. #4
    Hi,

    Your sample raises server side exception.
    Please provide test sample which is not required any changes from our side
  5. #5
    I just reran here, and I am not getting any server side exception. It is a simple code based on simple array grid, from examples.ext.net.

    Can you please post details on what exception you are getting?

    The only thing I can think is getting an exception to you is this line:

            var panel = eventArgs.Item.FindControl("Panel1") as Ext.Net.Panel;
    I cant tell if your computer is generating a different id for the Panel1.
  6. #6
    Vladimir, try under VS 2010. It runs fine.

    But under VS 2008 it really throws the exception.

    Also I should say that the sample really reproduce the problem.
  7. #7
    Thanks, Daniil.

    Additional info: I am running it under vs 2010, c# 4.0
  8. #8
    Hi,

    It is very strange design to use ListView templates to generate controls and then move it to another controls
    It seems ASP.NET doesn't like inner controls with ID in the template controls
    if you remove ID for GridView then all works fine. If ID is presented then FindControl method raises exception, it is reproducable with ASP.NET controls also
    See the following sample
    <%@ Page Language="C#" %>
     
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var dt = new DataTable();
                dt.Columns.Add("Column1");
                dt.Columns.Add("Column2");
                var dr = dt.NewRow();
                var dr2 = dt.NewRow();
     
                dt.Rows.Add(dr);
                dt.Rows.Add(dr2);
                ListViewGrid.DataSource = dt;
                ListViewGrid.DataBind();
    
                Control w1 = this.Page.Form.FindControl("Window1");
    
                X.Msg.Alert("Controls", "Window1 - " + (w1 != null ? "found" : "not found")).Show();
            }
        }
     
        protected void ListViewList_ItemDataBound(object sender, ListViewItemEventArgs eventArgs)
        {
            var panel = eventArgs.Item.FindControl("Panel1");
            panel.ID = "p" + PanelsHolder.Controls.Count;
            PanelsHolder.Controls.Add(panel);
        }
     
     
    </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>Simple Array Grid - Ext.NET Examples</title>
        <ext:ResourcePlaceHolder runat="server" />
        <ext:XScript runat="server">
        <script type="text/javascript">
        function id() 
        {
            #{Label1};
            #{Window1}.getId();
        }
        </script>
        </ext:XScript>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Label ID="Label1" runat="server" />
    
        <asp:Panel ID="PanelsHolder" runat="server">
        </asp:Panel>
        
        <asp:ListView OnItemDataBound="ListViewList_ItemDataBound" ID="ListViewGrid" runat="server">   
            <ItemTemplate>
                <asp:Panel ID="Panel1" runat="server">
                    <asp:GridView ID="GridView1" runat="server" />
                </asp:Panel>
                <ext:Button Text="Open Window" runat="server">
                    <Listeners>
                        <Click Handler="#{Window1}.show();" />
                    </Listeners>
                </ext:Button>
            </ItemTemplate>
        </asp:ListView>
        <ext:Window Hidden="true" runat="server" ID="Window1">
            <Items>
                <ext:Label Text="1" runat="server" />
            </Items>
        </ext:Window>
        </form>
    </body>
    </html>
  9. #9
    I had to go with this design so I could create tabs for tabpanel dynamically without creating everything in the codebehind. I first populate the listview, then I attach it to tabpanel.

    In your example, if you leave the ID in GridView it wont work, since it is creating two controls with the same ID.

    Remove gridview's ID and rerun the code. The problem with XSciprt is still there, look:

        <script type="text/javascript">
        function id()
        {
            Label1;
            Ext.get("Window1").getId();
        }
        </script>
  10. #10
    Hi,

    For me If remove ID for GridView then #{Window1} is parsed correctly.
    What meesage do you see: "found" or "not found"?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Update Asp Net Label inside asp ListView in Directmethod
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 26, 2012, 2:54 PM
  2. How we can wrap the listview column content?
    By NishaLijo in forum 1.x Help
    Replies: 0
    Last Post: Mar 27, 2012, 7:42 AM
  3. Replies: 2
    Last Post: Nov 04, 2011, 6:06 PM
  4. How to use ASP.NET content inside EXT.NET content
    By Janaka360 in forum 1.x Help
    Replies: 2
    Last Post: May 09, 2011, 4:21 AM
  5. Replies: 0
    Last Post: Oct 19, 2010, 7:39 AM

Posting Permissions