Persist js用户控制状态 [英] Persist js user controls state

查看:167
本文介绍了Persist js用户控制状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的RIA应用程序有很多js UI控件(几乎所有的都是jQuery UI部分,如datepicker,dialog,jqgrid)。那么用户在一个页面上使用某些控件,然后转到另一个页面,然后点击所有页面组件都有初始状态(文本框为空,网格为空等)。那么如何才能保持UI控件状态,然后在页面之间恢复?看来我需要一些像在序列化数据存储在用户服务器会话中的JS序列化/反序列化方法。我如何以最低的成本来做到这一点?你们在项目中怎么样?任何事情,链接,职位都将非常感激。谢谢你们提前!



P.S。我的项目是ASP .NET MVC3






编辑



现在我记得有关memnto的设计模式。任何人都可以向我提供与这个想法有关的内容吗?
再次感谢!

解决方案

我将此写成您的问题的评论,但我将其作为答案因为它可能是唯一的方法,而不必用某种侧插件劈它。



使用Viewstate与您无关或者不是JQuery UI插件。所有您需要做的是使用服务器端控件。



请注意,为此,您必须使用控制客户端名称,如:

  $('#<%= MyDateTextbox.ClientID%>')。datepicker(); 

这样,您可以在服务器端控件上应用JQuery UI,并利用Viewstate恢复控件后退导航值。


My RIA application has a lot js UI controls (almost all of their is jQuery UI parts like datepicker, dialog, jqgrid). So then user works with some controls on one page and then go to another page and then clicks back all page components has initial state (textboxes are empty, grids are empty and so on). So how can I persist UI controls state and then restoring it between pages? It seems I need some like JS serialization/deserialization methods storing serialized data in user server session. How can I do it with minimal costs? How do you guys it in your projects? Any thougs, links, posts will be very appreciated. Thank you guys in advance!

P.S. My project is ASP .NET MVC3


EDIT

Just now I remember about memnto design pattern. Could anyone of you advice me something related to this idea? Thanks again!

解决方案

I wrote this as a comment of your question but I'm putting it as an answer as it might be the only way to do this without having to "hack" it with some sort of side plugins.

The use of Viewstate have nothing to do with you using or not JQuery UI "addins". All you have to do is use server-side controls instead.

Note that for this you have to use the control client-side name, something like:

$('#<%= MyDateTextbox.ClientID %>').datepicker(); 

This way you can apply JQuery UI on server-side controls and take advantage of the Viewstate restoring the controls value on back-button navigation.

这篇关于Persist js用户控制状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆