Apollon
Apollon

Reputation: 331

Image is not updated inside an update panel.Asp.net c#

I have one asp page with three update panels.In first two there are one gridview and one chart.These two controls are updated correctly after 30seconds(my timer interval).This is the gridview.

    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManagerLiveStats" runat="server">
</ajaxToolkit:ToolkitScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"
        ViewStateMode="Enabled">
<ContentTemplate>
    <asp:GridView ID="GridViewQScore" runat="server" OnRowCreated="gvHover_RowCreated"></asp:GridView>
</ContentTemplate>
<Triggers>
   <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
 </asp:UpdatePanel> 

   <asp:Timer ID="Timer1" runat="server" Interval="30000" OnTick="Timer1_Tick"  ></asp:Timer>

the same thing is for the asp:chart

The problem is in the asp:image tag that is not updated after 30 seconds.You must refresh the page to update. I use this code :

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"
        ViewStateMode="Enabled">
    <ContentTemplate><asp:Image runat="server" ID="image1" ImageUrl="~/images/livescoretableOut.jpg" /></ContentTemplate>
   <Triggers>
     <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
   </Triggers>
   </asp:UpdatePanel> 

I also try using a div and set its background to the preffered image but also is not updated :

    <div runat="server" style="background-image: url(../images/BackgroundLivePgameContainer.jpg)"></div>

Any idea why the update panel is not working with asp:image and also with Div?

Upvotes: 0

Views: 3341

Answers (2)

Ali zain javed
Ali zain javed

Reputation: 1

<asp:FileUpload ID="FileUpload1" runat="server" />


Upvotes: 0

Apollon
Apollon

Reputation: 331

Finally the problem is solved from here http://www.codeproject.com/Tips/340439/How-to-Solve-Image-Refresh-problem-associated-with?msg=4818359#xx4818359xx

     protected void Timer1_Tick(object sender, EventArgs e)
{   
    image1.ImageUrl = "images/livesOut.jpg" + "?time=" + DateTime.Now.ToString();             
}

Upvotes: 1

Related Questions