[CLOSED] Button in a listview with a loginview

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Button in a listview with a loginview

    Gentlemens,

    I dont know what is going on with my code.

    When I have <asp:LoginView runat="server">, my buttons dont work. As soon as I remove the runat="server", leaving <asp:LoginView>, they work again.

    Bellow is the source code. I am using forms authentication.

    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)
        {
            var dataTable = new DataTable();
            var dataColumn = new DataColumn("Column1");
    
            dataTable.Columns.Add(dataColumn);
    
            var row1 = dataTable.NewRow();
            var row2 = dataTable.NewRow();
    
            row1["Column1"] = "column1";
            row2["Column1"] = "column2";
    
            dataTable.Rows.Add(row1);
            dataTable.Rows.Add(row2);
    
            ListView1.DataSource = dataTable;
            ListView1.DataBind();
    
        }
    
        protected void Test(object sender, EventArgs e)
        {
    
            X.Msg.Alert((sender as Ext.Net.Button).Tag.ToString(), (sender as Ext.Net.Button).Tag.ToString()).Show();
        }
    </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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <asp:ListView ID="ListView1" runat="server">
            <ItemTemplate>
                <asp:LoginView runat="server">
                    <LoggedInTemplate>
                        <ext:Button runat="server" Icon="CartGo" StyleSpec="margin: 0 auto;" Text="Comprar"
                            OnClick="Test" Tag='<%# Eval("Column1") %>' AutoPostBack="true" runat="server" />
                    </LoggedInTemplate>
                </asp:LoginView>
            </ItemTemplate>
        </asp:ListView>
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 18, 2011 at 11:38 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please provide more details regarding to "my buttons dont work".

    Does a postback occur? Does it not logs in?

    Please try also with a common <asp:Button>. What does happen?
  3. #3
    Hi!

    Sorry for the lack of details.

    Post back occurs on both, but:

    1. Asp buttons enters the 'Test' method.
    2. Ext.Net does not enter the 'Test' method.

    Here is an updated version:

    <%@ Page Language="C#" EnableEventValidation="false" %>
     
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
     
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataTable = new DataTable();
            var dataColumn = new DataColumn("Column1");
     
            dataTable.Columns.Add(dataColumn);
     
            var row1 = dataTable.NewRow();
            var row2 = dataTable.NewRow();
     
            row1["Column1"] = "column1";
            row2["Column1"] = "column2";
     
            dataTable.Rows.Add(row1);
            dataTable.Rows.Add(row2);
     
            ListView1.DataSource = dataTable;
            ListView1.DataBind();
     
        }
     
        protected void Test(object sender, EventArgs e)
        {
            X.Msg.Alert("123", "123").Show();
        }
        
    </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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <asp:ListView ID="ListView1" runat="server">
            <ItemTemplate>
                <asp:LoginView runat="server">
                    <LoggedInTemplate>
                        <ext:Button runat="server" Icon="CartGo" StyleSpec="margin: 0 auto;" Text="Comprar"
                            OnClick="Test" Tag='<%# Eval("Column1") %>' AutoPostBack="true" />
                        <asp:Button runat="server" Icon="CartGo" StyleSpec="margin: 0 auto;" Text="Comprar"
                            OnClick="Test" Tag='<%# Eval("Column1") %>' AutoPostBack="true" />
                    </LoggedInTemplate>
                </asp:LoginView>
            </ItemTemplate>
        </asp:ListView>
        </form>
    </body>
    </html>
  4. #4
    We reproduced the problem but we was unable to determine the why it occurs
    It seems ASP.NET requires something special in this particular case
    We found one difference between ASP.NET button and Ext.Net button
    ASP.NET button uses 'input' element (therefore it's name is presented in the posted collection) but Ext.Net button uses 'button' element and update EVENTTARGET to inform server about postback target

    We will try to find solution but i am not sure (it is required to investigate source code of ASP.NET to understand why postabck event handler is not called by ASP.NET)
  5. #5
    Vladmir, thanks for the feedback.

    Take your time. My website is still in development stage, so, no hurry!
  6. #6
    We would also recommend to consider generating all things in code behind instead of using an <asp:ListView>.

    Another possible solution can be programmatically clicking a hidden <asp:Button>.

    We are still not sure that we can fix it. It might be a bug in ASP.NET or a not documented restriction.

    But, certainly, we'll try.
  7. #7
    Luckly, the dll I was using that required me to use autpostback just got updated, and, now, I can use the directeventargs, which functions alright with loginview.

    If you guys want, you can close this thread.

    Thanks.
  8. #8
    Quote Originally Posted by SouthDeveloper View Post
    I cant use the directeventargs, which functions alright with loginview.
    Seems it's obvious, but to clarify: there should "can" instead "cant", isn't that so?
  9. #9
    You are right ;)

    I just edited the message.
  10. #10
    I'd prefer to close this thread if you don't mind.

    Though we can review it in the future.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] LoginView with LinkButton
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 04, 2012, 11:16 AM
  2. [CLOSED] Error with DirectEventin LoginView
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 14
    Last Post: Apr 23, 2012, 2:07 PM
  3. Is it possible to add button in a listview
    By NishaLijo in forum 1.x Help
    Replies: 1
    Last Post: Mar 26, 2012, 7:08 PM
  4. [CLOSED] asp listview with ext button
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 06, 2011, 2:27 PM
  5. How to use LoginView with coolite
    By jidaneri in forum 1.x Help
    Replies: 2
    Last Post: Mar 11, 2010, 6:22 PM

Posting Permissions