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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
如果你想在使用 `van-pull-refresh` 组件的同时实现滑动加载数据的功能,可以结合使用 `van-pull-refresh` 和 `van-list` 组件。 首先,在模板中使用 `van-pull-refresh` 和 `van-list` 组件来创建下拉刷新和滑动加载的效果。示例如下: ```vue <template> <div> <van-pull-refresh @refresh="onRefresh"> <van-list v-model="list" :finished="finished" @load="onLoad"> <template #default="{ item }"> <!-- 渲染每个数据项的内容 --> <van-cell :title="item.title" :value="item.value" /> </template> </van-list> </van-pull-refresh> </div> </template> <script> export default { data() { return { list: [], // 初始化为空数组 finished: false, // 滑动加载是否已完成 page: 1, // 当前页码 }; }, methods: { onRefresh() { // 下拉刷新时的逻辑 // 可以发送异步请求获取最新数据 // 示例中使用 setTimeout 模拟异步请求 setTimeout(() => { // 假设请求返回的数据是数组 const data = [ { title: 'Title 1', value: 'Value 1' }, { title: 'Title 2', value: 'Value 2' }, { title: 'Title 3', value: 'Value 3' }, ]; // 更新列表数据 this.list = data; // 取消下拉刷新状态 this.$refs.pullRefresh.finishPullDown(); }, 1000); }, onLoad() { // 滑动加载时的逻辑 // 可以发送异步请求获取更多数据 // 示例中使用 setTimeout 模拟异步请求 setTimeout(() => { // 假设请求返回的数据是数组 const data = [ { title: 'Title 4', value: 'Value 4' }, { title: 'Title 5', value: 'Value 5' }, { title: 'Title 6', value: 'Value 6' }, ]; // 更新列表数据 this.list = this.list.concat(data); // 如果已加载完所有数据,设置 finished 为 true if (this.page >= 3) { this.finished = true; } // 加载完成后调用 finishLoad 方法 this.$refs.list.finishLoad(); // 增加页码 this.page++; }, 1000); }, }, }; </script> ``` 在上述示例中,`van-pull-refresh` 组件用于实现下拉刷新的效果,当下拉刷新触发时,会调用 `onRefresh` 方法。在 `onRefresh` 方法中,可以发送异步请求获取最新的数据,并更新列表数据。最后,通过 `finishPullDown` 方法取消下拉刷新状态。 `van-list` 组件用于实现滑动加载的效果,当滑动加载触发时,会调用 `onLoad` 方法。在 `onLoad` 方法中,可以发送异步请求获取更多的数据,并更新列表数据。通过 `finishLoad` 方法告知组件加载完成。 请注意,以上示例中的异步请求使用了 setTimeout 来模拟,实际情况下需要使用适当的方式发送请求。另外,根据具体需求,你可能需要调整代码来满足你的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值