Autor Beitrag
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Do 11.03.10 14:41 
Hallo zusammen,

ich habe ein UpdatePanel in dem ich ein asp:Chart (Image) anzeige. Diese Anzeige will ich per Knopfdruck oder automatisch über einen Timer updaten. Hierfür hab ich grob folgenden Code:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
<asp:UpdatePanel runat="server" ID="ChartPanel" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="bUpateP2_Click" Enabled="false"/>                    
                    <asp:Button ID="bUpdate" runat="server" Height="40px" OnClick="bUpateP2_Click" Text="Update"/>
                
                    <asp:Chart ID="Chart1" ...>
                        ...
                    </asp:Chart>
                    
                    <asp:UpdateProgress ID="UpdateProgress2" runat="server" 
                        AssociatedUpdatePanelID="ChartPanel"
                        DisplayAfter="80" DynamicLayout="true">
                        <ProgressTemplate>
                            <img alt="Loading" border="0" style="position: relative; top: -305px; z-index: 5; height: 305px; width: 398px;"  src="images/loading_wh.gif" />
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </ContentTemplate>
                
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                    <asp:AsyncPostBackTrigger ControlID="bUpdate" EventName="Click"/>
                </Triggers>
            </asp:UpdatePanel>


Dies Funktioniert wunderbar. Allerdings (weil innerhalb des UpdatePanelContents) wird GET der Button sowie der Timer neu angefordert. Deshalb will ich Diese aus dem UpdatePanel herausziehen. Damit das Panel trotzdem aktualisiert wird, sind diese zwei Controls als Trigger registriert. Somit Funktioniert folgender Code auch:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
      <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="bUpateP2_Click" Enabled="false"/>                    
        <asp:Button ID="bUpdate" runat="server" Height="40px" OnClick="bUpateP2_Click" Text="Update"/>
        
        <div id="chart">
            <asp:UpdatePanel runat="server" ID="ChartPanel" UpdateMode="Conditional">
                <ContentTemplate>
                
                    <asp:Chart ID="Chart1" runat="server" Height="305px" ImageUrl="~/TempImages/ChartPic_#SEQ(300,3)"
                        BackColor="211, 223, 240" BorderLineStyle="Solid"  BackGradientEndColor="White"
                        BackGradientType="TopBottom" BorderlineWidth="2" BorderlineColor="26, 59, 105"
                        EnableViewState="True" Width="398px">
                        ....
                    </asp:Chart>
                    
                    <asp:UpdateProgress ID="UpdateProgress2" runat="server" 
                        AssociatedUpdatePanelID="ChartPanel"
                        DisplayAfter="80" DynamicLayout="true">
                        <ProgressTemplate>
                            <img alt="Loading" border="0" style="position: relative; top: -305px; z-index: 5; height: 305px; width: 398px;"  src="images/loading_wh.gif" />
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </ContentTemplate>
                
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                    <asp:AsyncPostBackTrigger ControlID="bUpdate" EventName="Click"/>
                </Triggers>
            </asp:UpdatePanel>
        </div>


Soweit zu meinem Stand, nun das Problem:
Wenn ich den Trigger bzw. den Update-Button außerhalb des UpdatePanel ContentTemplate definiere wird beim Update-Progress das dafür vorgesehen Image nicht angezeigt. Die anderen Funktionalitäten funktionieren (nur Teil der Seite wird erneuert).

Ich hoffe ich hab meine Anlegen klar erläutert und das mir jemand helfen kann.

Danke & Gruß
Daniel