zoukankan      html  css  js  c++  java
  • C#How to refresh ASPxImage using ASPxCallbackPanel

    How to refresh ASPxImage using ASPxCallbackPanel

    Tags:

    Sylo6 years ago

      • Hi,

        I have an ASPXImage in an aspxcallbackPanel
        The aspximage.imageurl="image.gif"

        If I change the image on the server (create a new image and save it with the same name "image.gif") and do a callback, the Image of the aspximage is not refresh and keep the last image.

        I don't know if it's normal but how I can obtain an automatic refresh ?

        Thanks
        Sylo

    •  

    Leave a Comment

    1 Solution

    Sergi (DevExpress Support)6 years ago

    •  
    •  

    Hi Sylo,

    It should be possible to accomplish this task by using the ASPxCallbackPanel. Please make sure that you are not sending a postback along with a callback. This may cause the incorrect behavior.
    See the code below:

    
     

    [ASPx]

    <dx:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server" ClientInstanceName="panel" OnCallback="ASPxCallbackPanel1_Callback" Width="200px"> <PanelCollection> <dx:PanelContent runat="server"> <dx:ASPxImage ID="ASPxImage1" runat="server" ImageUrl="~/Images/Image1.png" ShowLoadingImage="true"></dx:ASPxImage> </dx:PanelContent> </PanelCollection> </dx:ASPxCallbackPanel> <dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="false" Text="ASPxButton"> <ClientSideEvents Click="function(s, e) { panel.PerformCallback(); }" /> </dx:ASPxButton>

    
     

    [C#]

    protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { ASPxCallbackPanel panel = (ASPxCallbackPanel)sender; ASPxImage image = (ASPxImage)panel.FindControl("ASPxImage1"); image.ImageUrl = "~/Images/Image2.png"; }

    
     

    [VB.NET]

    Protected Sub ASPxCallbackPanel1_Callback(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxClasses.CallbackEventArgsBase) Dim panel As ASPxCallbackPanel = CType(sender, ASPxCallbackPanel) Dim image As ASPxImage = CType(panel.FindControl("ASPxImage1"), ASPxImage) image.ImageUrl = "~/Images/Image2.png" End Sub

    Feel free to contact us if you need further clarification on this issue.

    UPDATED:

    Thank you for your clarification. This issue is related to the fact that browser does not reload images with the same url on callbacks.
    You can try the approaches posted in the Refresh image with a new one at the same url article to avoid this issue.

    • Sylo6 years ago

      Hi Sergi,
      Thanks for your answer
      But in my case, the image have the same name... The image in the file change but not the name of the file...
      Is it more clear ?
      Thanks
      Sylo

    • Sergi (DevExpress Support)6 years ago

      Hi Sylo,

      Thank you for your clarification. This issue is related to the fact that browser does not reload images with the same url on callbacks.
      You can try the approaches posted in the Refresh image with a new one at the same url article to avoid this issue.

    • Sylo6 years ago

      Good idea, thanks Sergi

  • 相关阅读:
    PAT 甲级 1126 Eulerian Path (25 分)
    PAT 甲级 1126 Eulerian Path (25 分)
    PAT 甲级 1125 Chain the Ropes (25 分)
    PAT 甲级 1125 Chain the Ropes (25 分)
    PAT 甲级 1124 Raffle for Weibo Followers (20 分)
    PAT 甲级 1124 Raffle for Weibo Followers (20 分)
    PAT 甲级 1131 Subway Map (30 分)
    PAT 甲级 1131 Subway Map (30 分)
    AcWing 906. 区间分组 区间贪心
    AcWing 907. 区间覆盖 区间贪心
  • 原文地址:https://www.cnblogs.com/grj001/p/12223893.html
Copyright © 2011-2022 走看看