zoukankan      html  css  js  c++  java
  • Asp.net使用DevExpress的某些控件不能操作ViewState的解决方案

    博主现在项目中需要大量用DevExpress控件,以下简称dev,第一印象还算不错,多种主题切换,强大的数据展示功能支撑,使开发者在数据的展示方面节省了大量时间。

    在表单的增删查改方面,用了ASPxCallback和ASPxCallbackPanel控件,ASPxCallback主要用于异步回发处理数据,只是不能改变UI,而ASPxCallbackPanel的强大之处补充了ASPxCallback的不足,ASPxCallbackPanel就是一个面板,我们可以看作是MS自带的UpdatePanel,ASPxCallback和ASPxCallbackPanel的功能非常强大,支持很多前端事件,在这里就不在赘述,相信使用dev的朋友们深有体会。

    问题来了,使用ASPxCallback、ASPxCallbackPanel、ASPxGridView等的OnCallback后台事件时用来保存ViewState时发现当时改变了,但是页面再次回发却又恢复成了改变之前的值,为此郁闷不已,进官网找答案。

    先来看提问的问题:

    I am trying to save my data that populates the TreeList in a ViewState. When nodes are editted, I want to update their values in the ViewState. But no changes seem to be saved in the ViewState. The Page.SaveViewState method is not even called after an edit or after a tree is expanded (it is only called on first page load).
    Why can't I update the Page ViewState from one of the AJAX callbacks from a TreeList? Do I need to do something to allow the ViewState to be changed during postbacks from the TreeList?

    看来这位朋友和我的问题一样

    再看有用的答案:

    The ViewState is stored in a hidden field which is rendered in the page's header. During a callback, the client receives the content of the control which initiated this callback. ViewState is not sent to the client (since it sits in the header) and our controls cannot embed it in the response and then update the corresponding hidden field. A possible solution is to set the ASPxTreeList's EnableCallbacks property value to false, and use the ASPxTreeList on the MS UpdatePanel. It will be able to intercept a TreeList's postbacks and "convert" them to callbacks. It is also able to update the ViewState.

    回答者说出了dev的响应原理和解决方法:将dev控件的EnableCallbacks属性设为false,然后外面套UpdatePanel即可解决,一试果然解决问题。

    看来,UpdatePanel拦截了dev的postback,然后UpdatePanel自身去更新ViewState,到此,问题解决。

    参考资料:http://www.devexpress.com/Support/Center/Question/Details/Q208774

  • 相关阅读:
    开发者账号续期后,itunes停止付款了
    复杂sql分组查询 ( pivot)
    免费真机调试 -- Xcode7
    System.Security.Cryptography.CryptographicException: 指定了无效的提供程序类型
    phonegap创建的ios项目推送消息出现闪退现象
    这周的《财经郎眼
    <转>iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!
    ios线程和GCD和队列同步异步的关系
    <转>关于Certificate、Provisioning Profile、App ID的介绍及其之间的关系
    为什么我们要做单元测试?(二)
  • 原文地址:https://www.cnblogs.com/laozhao8/p/3080346.html
Copyright © 2011-2022 走看看