C# 如何使用 Razor 在 ASP.NET MVC3 中创建选项卡视图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9214794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 06:23:59  来源:igfitidea点击:

How to create tabs view in ASP.NET MVC3 with Razor?

c#asp.net-mvc-3razortabs

提问by CiccioMiami

I am developing a web application in ASP.NET MVC3 with C# and Razor. I need to create tabs within my web page, exactly as it is displayed in browsers.

我正在使用 C# 和 Razor 在 ASP.NET MVC3 中开发 Web 应用程序。我需要在我的网页中创建标签,就像它在浏览器中显示的那样。

I don't know if there is already a template made available by MVC3 or creating tabs is an easier task than I think. Actually it is the first time ever I've been asked to do it.

我不知道 MVC3 是否已经提供了一个模板,或者创建选项卡比我想象的要容易。事实上,这是我第一次被要求这样做。

Anybody has some advice or suggestion? At the beginning I plan to do it with postbacks in order not to lose too much time with jQuery or other client technologies. Thank you very much :D

有人有什么建议或建议吗?一开始我计划用回发来做这件事,以免在 jQuery 或其他客户端技术上浪费太多时间。非常感谢:D

采纳答案by Darthg8r

In my opinion, the time you'd "lose" from learning jQuery (depending on your familiarity with JavaScript/jQuery) would be well worth the time you'd spend on having to play around with the HTML and CSS to get decent looking tabs.

在我看来,你在学习 jQuery 中“失去”的时间(取决于你对 JavaScript/jQuery 的熟悉程度)将非常值得你花时间去玩 HTML 和 CSS 以获得体面的标签.

The jQuery UI Tabsare easy to set up, and very responsive and nice to look at.

jQuery UI的标签很容易成立,并非常敏感和好看。

回答by Darthg8r

The default templates from MVC have a simple tab system in place for navigation that is based on simple css.

MVC 的默认模板有一个简单的标签系统,用于基于简单 css 的导航。

You should have a look at those. I know that you said that you wanted to avoid jQuery for this, but they don't have a significant learning curve and there are hundreds of examples of their use on the web.

你应该看看那些。我知道你说过你想为此避免使用 jQuery,但它们没有明显的学习曲线,而且网上有数百个使用它们的示例。

http://jqueryui.com/demos/tabs/in conjunction with PartialViewResults and jquery ajax can be a powerful tool.
ASP.NET MVC 2 loading partial view using jQuery - no client side validation

http://jqueryui.com/demos/tabs/结合 PartialViewResults 和 jquery ajax 可以成为一个强大的工具。
ASP.NET MVC 2 使用 jQuery 加载部分视图 - 没有客户端验证