ASP.NET MVC在View中输出的问题

siaosa 2015-06-30 05:11:40
ASP.NET MVC在View中输出的问题,详见下面的代码:


@{
for (var i = 0; i < 5; i++)
{
if (i==0)
{
<div style="display:block">
.........
}
else
{
<div style="display:none">
.......
}
........
</div> ===>DIV结束标志, 这样输出, 会报错,要怎么修改才对啊?
}
}
...全文
217 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zj25810 2015-07-02
  • 打赏
  • 举报
回复
            @{
               for (var i = 0; i < 5; i++)
               {
                   if (i==0)
                   {
                      <div style="display:block">                              
                       .........
                    }
                    else
                    {
                      <div style="display:none">
                        .......
 ........
                     }
                          
                       </div>                      ===>DIV结束标志, 这样输出, 会报错,要怎么修改才对啊?
                 }                        
              }
编程有钱人了 2015-07-02
  • 打赏
  • 举报
回复


            @{
               for (var i = 0; i < 5; i++)
               {
                   if (i==0)
                   {
                      <div style="display:block">                              
                        </div>         
                    }
                    else
                    {
                      <div style="display:none">
                     </div>         
                     }
                 }                        
              }

这样写就是麻烦点
newtee 2015-06-30
  • 打赏
  • 举报
回复
用text @if (HttpContext.Current.User.Identity.IsAuthenticated) { <text> <ul class="nav pull-right"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">@User.Identity.Name<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="/account/profile">我的个人资料</a></li> <li class="divider"></li> <li><a href="/@User.Identity.Name">我的博客</a></li> <li><a href="/@User.Identity.Name/album/">我的相册</a></li> </ul> </li> <li class="divider-vertical"></li> <li> @using (Html.BeginForm("logOff", "account", FormMethod.Post, new { id = "logoutForm" })) { @Html.AntiForgeryToken() <a href="javascript:document.getElementById('logoutForm').submit()">注销</a>} </li> </ul> </text> } else { <ul class="nav pull-right"> <li>@Html.ActionLink("注册", "register", "account")</li> <li class="divider-vertical"></li> <li>@Html.ActionLink("登录", "login", "account")</li> </ul> }
Rajesh_James 2015-06-30
  • 打赏
  • 举报
回复

            @{
               for (var i = 0; i < 5; i++)
               {
                   if (i==0)
                   {
                      <div style="display:block">                              
                       .........
                    }
                    else
                    {
                      <div style="display:none">
                        .......
 ........
                       </div>                      ===>DIV结束标志, 这样输出, 会报错,要怎么修改才对啊?
                     }
                         
                 }                        
              }
An outstanding author team presents the ultimate Wrox guide to ASP.NET MVC 4 Microsoft insiders join giants of the software development community to offer this in-depth guide to ASP.NET MVC, an essential web development technology. Experienced .NET and ASP.NET developers will find all the important information they need to build dynamic, data-driven websites with ASP.NET and the newest release of Microsoft's Model-View-Controller technology. Featuring step-by-step guidance and lots of code samples, this guide gets you started and moves all the way to advanced topics, using plenty of examples. Designed to give experienced .NET and ASP.NET programmers everything needed to work with the newest version of MVC technology Expert author team includes Microsoft ASP.NET MVC insiders as well as leaders of the programming community Covers controllers, views, models, forms and HTML helpers, data annotation and validation, membership, authorization, security, and routing Includes essential topics such as Ajax and jQuery, NuGet, dependency injection, unit testing, extending MVC, and Razor Includes additional real-world coverage requested by readers of the previous edition as well as a new case study example chapter 下面是上一版书的文介绍 《ASP.NET MVC 3 高级编程》主要内容是描述视图的概念,探讨Razor语法、NuGet、单元测试等,解释控制器在MVC框架的作用,以及模型在绑定和数据访问策略发挥的作用,演示如何显示和处理表单,涵盖添加到April 2011 Tools Update的新特性,如基架和HTML5项目模板,展示在客户端和服务器端验证模型的过程给出利用成员资格、援权和安全特性的忠告,讲解将TDD应用于ASP.NET MVC的方法。
The Model-View-Controller pattern—universally known as MVC—provides a stable, testable approach to web application development by separating the major functions—or concerns—of an application into independently defined roles. Until now, developers needed to adopt third-party solutions such as Monorail because ASP.NET lacked a true MVC-based architecture. Microsoft's brand new ASP.NET MVC Framework now offers a fully-supported way for developers to implement MVC architectures in ASP.NET applications. ASP.NET MVC in Action is a comprehensive guide to MVC-based development using this powerful new framework. It offers a clearly-written introduction both to the ASP.NET MVC Framework and to the MVC approach. The focus is on creating real, maintainable web applications—so don't expect toy examples and short snippets. The authors lead you from first-use through real-life scenarios. One of the key benefits of the MVC approach is introducing a high degree of testability to your applications and process. ASP.NET MVC in Action shows you how to test each piece of your ASP.NET application and how to introduce principles of test-driven development into your process. Because the framework is completely pluggable, you'll learn how to work with external Inversion of Control containers like StructureMap, Windsor, and Spring.NET and open-source persistence layers like NHibernate. Along the way, you'll benefit from the wide-ranging experience of the authors, who have extensive experience with ASP.NET, Monorail, and Ruby on Rails. This book assumes that you already know how to build a standard ASP.NET application and presents most examples in C#.

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧