在 MVC 和 Razor 中创建向导步骤
我想构建一个 MVC 应用程序来使用多个向导步骤创建用户帐户。 我是否需要使用一个视图页面并通过客户端逻辑隐藏或显示 div,或者我是否需要为每个向导创建不同的视图(使用部分视图)?
这里最好的选择是什么?我需要在向导步骤之间维护状态数据,以便用户可以后退或下一步,并且在最后一步中他或她可以将其保存到数据库中。
I would like to build one MVC application to create the account of a user using more then one wizard steps.
Do I need to go with one view page and hide or display a div by client side logic or do I need to create different view for each wizard (using partial views)?
What is the best option here? I need to maintain state data between wizard steps so the user can move back or next and on last step he or she can save it to the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有不同的可能性。您可以通过显示/隐藏部分来使用纯客户端解决方案或完整的服务器端解决方案。由您决定哪一种最适合您的特定场景。如果您决定采用服务器端方法,可以查看以下示例。
There are different possibilities. You could use a pure client side solution by showing/hiding sections or a full server side solution. It's up to you to decide which one is best for your particular scenario. Here's an example you might take a look at if you decide to go the server side approach.
取决于您是否允许 javascript。
如果允许 JavaScript,请使用 jQuery 来显示/隐藏 div。
我刚刚制作了以下向导脚本。只要您遵循下面的 class/div 语法,它就支持同一页面上的多个向导。
不使用 javascript:
创建一个视图模型,其中包含所有步骤的信息并在所有向导步骤视图之间共享它。这允许您保留不同 POST 之间的所有状态。
Depends on if you allow javascript or not.
If you allow javascript, use jQuery to show/hide divs.
I just made the following wizard script. It supports multiple wizards on the same page, as long as you follow the class/div syntax below.
Without javascript:
Create a view model which contains information for all steps and share it between all wizard step views. This allows you to keep all state between the different POSTs.
我现在正在做类似的事情。我通过几个步骤收集大量数据,并允许用户随时保存数据。
我基本上将其分成多个视图,并为每个视图创建了 ViewModel,并提供了该向导步骤的相关信息。对于我的目的来说似乎工作得相当好。
I'm doing something similar at the moment. I'm collecting a large set of data over several steps and allowing the users to save the data at any point.
I've basically split it up into multiple views and created ViewModels for each view with the relevant info for that wizard step. Seems to be working reasonably well for my purposes.