Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Monday, March 26, 2012

TreeView populated programatically in Atlas UpdatePanel

Hi there,

I'm fairly new to Atlas and ASP.NET, so perhaps this question is obvious (I apologise).

I have created a page which essentially contains this information:

<asp:Content ID="Content1" ContentPlaceHolderID="MainPagePlaceholder" Runat="Server">
<atlas:UpdatePanel ID="AjaxMultiMediaPanel" mode="Conditional" runat="server">
<ContentTemplate>
<asp:Table ID="MultiMediaTable" CssClass="MultiMediaTable" runat="server" Height="193px" Width="274px">
<asp:TableRow runat="server">
<asp:TableCell runat="server" CssClass="TableTopAlign">
<cc1:MediaPlayer ID="MediaPlayer1" runat="server"></cc1:MediaPlayer>
<atlas:UpdateProgress runat="server" ID="progress">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/SpinningBall.gif" /> Reading UPnP Directory
</ProgressTemplate>
</atlas:UpdateProgress>
</asp:TableCell>
<asp:TableCell runat="server" CssClass="TableTopAlign">
<asp:TreeView ID="TreeView1" runat="server" >
<ParentNodeStyle CssClass="TreeParentNodeStyle" />
<HoverNodeStyle CssClass="TreeHooverStyle" />
<RootNodeStyle CssClass="TreeRootNodeStyle" />
<LeafNodeStyle CssClass="TreeLeafStyle" />
<NodeStyle CssClass="TreeNodeStyle" />
</asp:TreeView>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Play" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Load UPnP Info" />
</asp:TableCell>
<asp:TableCell>
<asp:Label ID="Label1" runat="server" Text="" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ContentTemplate>
</atlas:UpdatePanel
</asp:Content>

When Button2 is pressed, I programatically populate the TreeView (using c# to recursively build the tree). This works without problems when I do NOT use Atlas, except of course in that case the page refreshes after about 10 seconds. Now, using the code above, The Progress Update image and text is shown for about 10 seconds, but after that the page 'freezes' for over a minute. I have tried triggers to force a refresh, programatically forcing a refresh, but nothing helps. If I at the end of my tree-population code turn set TreeView1.Visible = false; then the page does not freeze.


It appears that the population of the treeview somehow causes Atlas to do 'something' for an awful long time.

If possible, I would appreciate any help any of you experts can offer.

- Anders

P.S. The tree has a depth of about 4-5 levels max, with about 100 items. Nothing crazy. The 10 second delay is due to some other UPnP lookups I'm doing, not because it takes a long time to build the tree.

See also:similar discussion

A count of my items reveals 2685 of them, a bit more than stated above.


Hi Anders

Did you ever find out a solution to this problem? I have been having the same problem where a TreeView inside an UpdatePanel takes a very long time to refresh.

Using Fiddler, I found out that the problem is the various images used by the TreeView control. Outside an UpdatePanel, the browser makes only one request for an image, regardless of the number of times its used. Inside the UpdatePanel, the browser makes a request for each and every instance of an image.

I don't know if this is a problem with the IE cache or the way Atlas is processing the resulting page.

The solution to this has so far eluded me. The only thing I can do is to reduce the number of images used by the TreeView control, but that quickly makes it useless.

Cheers,

- Dan


Hi Dan,

No solution so far. I had to drop it and just create the site using other widgets. Not quite as cool, but at least it works.


http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls

I had same problem. Finally, I setup a full postback trigger to the control that will force the repaint.
In my case, I had a button so my trigger code look like this:
<Triggers>
<asp:PostBackTriggerControlID="btnBack"/>
<asp:PostBackTriggerControlID="btnNext"/>
</Triggers>


I had the same problem, but I am still using Atlas, I don't wanna update until official version. And atlas UpdatePanel does not have PostBackTrigger, do you know how to solve it this problem witt Atlas?
If you haven't upgraded to the latest version by now, then you're going to be in a world of hurt when the RTM is released. There have been MANY breaking changes from ATLAS and it would be wise to forget ATLAS and move forward.

Trigger inside user control wont work

My Page contains a DataGrid inside UpdatePanel and a Filter user control.
I want to set a trigger to the UpdatePanel which refer to a button inside the Filter user control.

I get this error:
A control with ID 'Filter1_btnGo1' could not be found for the trigger in UpdatePanel 'UpdatePanel'.

how do I make this work?

Have you tried:

UpdatePanel.FindControl()

You pass in the control ID.

If you still have a problem, supply some sample code and I'll have another look.


Here is a small and simple code example to show the problem, have a look ...

1. TestUpdatePanel.aspx

<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="TestUpdatePanel.aspx.cs" Inherits="Test.TestUpdatePanel" %>
<%@. Register TagPrefix="UC" TagName="OutSideTrigger" src="http://pics.10026.com/?src=MyUserControl.ascx" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " +
DateTime.Now.ToString();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanel Tutorial</title>
<style type="text/css">
#UpdatePanel1 {
width:300px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn1" />
<asp:AsyncPostBackTrigger ControlID="uc1_UCButton" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btn1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
<UC:OutSideTrigger id="uc1" runat="server"></UC:OutSideTrigger>

</form>
</body>
</html>

2. MyUserControl.ascx

<%@. Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="Test.MyUserControl" %>

<div style="height:50;width:400;background-color=yellow">
<asp:Button ID="UCButton" runat="server" Text="Button should triger the update panel." />
</div>

Saturday, March 24, 2012

Triggering Update Panel from Dynamically Built Triggers

I have a page which has two content areas (Left, Center). The Left hand content contains two repeaters, both of which have an imagebutton who's itemcommand triggers an update of the content in the Center area. The Center Area has an update panel in it. The triggers are dynamically generated because the repeaters are in panels, and I needed to use the findcontrol() command to get access to them.

Code works great on my laptop (localhost), gives an error when I move it to the server. Error is:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing this request on the server. The status code returned from the server was: 500.

Here's my UpdatePanel:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Repeater ID="rMain" DataSourceID="srcMain" OnItemCommand="rmain_itemCommand" runat="server"> <ItemTemplate> <asp:Label ID="lblTitle" Text='<%#Eval("Description")%>' runat="server" CssClass="verorangeHeader" /><asp:Label ID="ProductID" runat="server" Text='<%# Eval("idProduct") %>' Visible="false"></asp:Label><asp:Label ID="lblSKU" runat="server" Text='<%# Eval("Sku") %>' Visible="False" /><br /><br /> <table border="0" cellpadding="1" cellspacing="1"> <tr> <td > <asp:Label ID="lblDetails" Text='<%#Eval("Details")%>' runat="server" CssClass="ver11bluebold" /> </td> <td ><img src='<%# formatPhoto(Eval("ImageURL")) %>' /></td> </tr> <tr> <td colspan="2" align="right" valign="top">Priced from: <asp:Label ID="lblPrice" Text='<%# formatPrice(Eval("Price")) %>' runat="server" CssClass="verorange" />   <asp:ImageButton ID="btnSpecifications" ImageURL="images/btn_specifications.gif" runat="server" /><asp:ImageButton ID="btnPhotoGallery" ImageURL="images/btn_photo-gallery.gif" runat="server" /><asp:ImageButton ID="btnBuyNow" ImageURL="images/buy-bm-clear.gif" runat="server" CommandName="Update" /></td> </tr> </table></ItemTemplate></asp:Repeater></ContentTemplate></asp:UpdatePanel>

Here's the code that creates the triggers:

Private Sub Page_Init(ByVal senderAs Object,ByVal eAs EventArgs)Handles MyBase.Init'Add TriggersDim ap1As AsyncPostBackTrigger =New AsyncPostBackTrigger()Dim ap2As AsyncPostBackTrigger =New AsyncPostBackTrigger() ap1.ControlID = pnlProduct1.FindControl("rY5").UniqueID ap1.EventName ="ItemCommand" ap2.ControlID = pnlProduct2.FindControl("r52").UniqueID ap2.EventName ="ItemCommand" UpdatePanel1.Triggers.Add(ap1) UpdatePanel1.Triggers.Add(ap2)End Sub

Any suggestions?

Jennifer

Take a look at this post...http://forums.asp.net/p/1139950/1831145.aspx

-Damien


Got it fixed. It was actually related to a bug in my Master Page!

Thanks for the help!

Jennifer


To fix this problem, you can add the follow code in your web.config

<system.web>
<pages validateRequest="false">
</system.web>.