Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] ASP.Net AJAX, not working with DataList?

Started by ferr Nov 9, 2008 at 1:33 AM 0 replies 4.7k views
Original Post
ferr
ferr
I have an asp:DataList with data in it including an asp:LinkButton that fires the DataList's item command handler which uses the WebClient.DownloadFileAsync method. I have a WebClient DownloadProgressChanged handler that I want to use to update an asp:Label asynchronously with the ProgressPercentage. I tried putting the label inside of an UpdatePanel, tried putting both the DataList and Label inside the UpdatePanel, and so forth, with no luck. The text on the page for the label does not change, even though when I debug into the DownloadProgressChanged handler the label is being updated accordingly. I know that there are a number of controls that are incompatible with UpdatePanel, I'm wondering if somewhere in this process something is suffering from a limitation. Or is it something else? I added in a button to test out if ajax was working at all, and I was able to update a label ajaxically. With that in mind I decided to switch out the LinkButton in the DataList with a regular Button, which should be compatible, and within the DataList's item command handler I tried updatng a label, but nothing happened. So I'm leaning towards the problem being with the DataList component.
    
public void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        pnlTransfer.Visible = true;
#region instr1
#endregion
        if (!System.IO.File.Exists(filename))
        {
            pnlVideoPlayer.Visible = false;
            pnlTransfer.Visible = true;
            wc.DownloadFileAsync(vUrl, filename);
        }
        else
        {
            pnlVideoPlayer.Visible = true;
            pnlTransfer.Visible = false;
        }
    }


    void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        lblTransfer.Text = "Transferring: " + e.ProgressPercentage.ToString() + "%";
    }



                
<asp:Panel ID="pnlVideoList" runat="server" style="margin-top: 22px" Width="495px" BackColor=LightGray Visible=false> <asp:DataList id="DataList1" runat="server" BorderColor="black" CellPadding="3" Font-Names="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="Gainsboro" OnItemCommand="DataList1_ItemCommand" Width=100% > <HeaderTemplate> Videos </HeaderTemplate> <ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "StringValue") %> <asp:linkbutton ID="Linkbutton2" Text="[Play]" CommandName='<%# DataBinder.Eval(Container.DataItem, "ID") %>' style="color:Black;font:8pt tahoma" runat="server"/>

</ItemTemplate> </asp:DataList> </asp:Panel>
...
<asp:Panel ID="pnlTransfer" runat="server" Visible=false> <asp:Label ID="lblTransfer" runat="server" Text="11"></asp:Label> </asp:Panel>
</ContentTemplate> </asp:UpdatePanel>
[Edited by - ferr on November 9, 2008 2:13:22 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.