简体   繁体   English

在客户端存储数据的最佳方式 - ASP.Net + JQuery

[英]Best way to store data on the client side - ASP.Net + JQuery

I'm writing an admin form for some fairly complex objects. 我正在为一些相当复杂的对象编写管理表单。 Its a standard repeater which displays some 'basic' information (name, id etc.) for each object row. 它是一个标准的转发器,显示每个对象行的一些“基本”信息(名称,ID等)。

Clicking 'Edit' for a row expands it (using JQuery) to reveal the full horror of all the associated editable objects. 单击行的“编辑”会扩展它(使用JQuery)以显示所有关联的可编辑对象的完整恐怖。 One of these is a list of documents associated with each row and needs to be JQuery-editable so the user could click 'edit' to open up the full row gui, then un/select checkboxes to de/associate documents and then hit 'Save' to persist everything. 其中一个是与每行相关联的文档列表,需要进行JQuery编辑,以便用户可以单击“编辑”打开完整行gui,然后取消/选择复选框以取消/关联文档然后点击“保存” '坚持一切。

Currently I'm using nested repeaters to store the initially-hidden fields - the repeater generates a hidden formfield containing a comma-separated list of IDs for the assoc documents. 目前我正在使用嵌套转发器来存储最初隐藏的字段 - 转发器生成一个隐藏的表单字段,其中包含关联文档的逗号分隔ID列表。 When it comes to populating the Edit gui I do a split operation on the delimited string and set/unset the checkboxes as required. 在填充Edit gui时,我在分隔字符串上执行拆分操作,并根据需要设置/取消设置复选框。

This is proving a nightmare from a maintainability perspective and in my frustrated wanderings of the web in search of a solution i noticed JQuery has some functionality to act as a client-side database. 从可维护性的角度来看,这是一场噩梦,在我寻找解决方案的网络徘徊中,我注意到JQuery有一些功能可以充当客户端数据库。 Does any one have any experience of this, and if so, would you recommend it? 有没有人有这方面的经验,如果有的话,你会推荐吗? My custom JS to parse csv-strings and dynamically build the gui is starting to grind me down a bit. 我的自定义JS解析csv-strings并动态构建gui开始让我陷入困境。

Thanks in advance, 提前致谢,

5arx 5arx

Your getting into the realm of very advanced client-side behavior, and are bumping into a phenomenon that I think a lot of Web Forms developers hit. 您进入了非常先进的客户端行为领域,并且正在碰到我认为很多Web窗体开发人员遇到的现象。 Trying to mash two paradigms into each other. 试图将两种范式混合在一起。

Without going into a lot of detail, my advice would be to go with a "Pure AJAX" approach to solving your client woes. 在没有详细介绍的情况下,我的建议是采用“纯AJAX”方法来解决客户问题。 The basic outline is this: 基本大纲如下:

You can implement the JSON stuff however you feel best suits your needs, but in ASP.Net you basically have two options: 你可以实现JSON的东西但是你认为最适合你的需求,但在ASP.Net中你基本上有两个选择:

  1. WCF WCF
  2. Page Methods 页面方法

It's probably going to involve some re-architecting on your part, but if you want to achieve really nice client-side behavior you are going to have to bite the bullet and just do it. 它可能会涉及到您的一些重新架构,但如果您想要实现非常好的客户端行为,您将不得不咬紧牙关而只是去做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM