MVC4视图中的错误(Razor) [英] Error in MVC4 View (Razor)

查看:80
本文介绍了MVC4视图中的错误(Razor)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 @model List< habg.Models.OtherServices> 

@using(Html.BeginUmbracoForm< habg.pocos.OtherservicesSurfaceController>(otherservices))
{
@ Html.AntiForgeryToken()
if(Model!) = null)
{

@if(模型!= null&& Model.Count> 0)
{
int j = 0;
foreach(var.in Model.FindAll(i => i.TourType == 1).ToList())
{
if(j == 0)
{
< h4>有组织的旅游< / h4>
< ul class =os_list>
}
< li>
@ Html.HiddenFor(a => a [j] .TourServiceId)
@ Html.HiddenFor(a => a [j] .BookingId)
< div class = imgHolder>< img src =@ System.Web.Configuration.WebConfigurationManager.AppSettings [AdminProductImage_VirtualPath] @ i.ImagePath/>< / div><! - imgHolder - >
< div class =imgInfo>
@ i.TourService_Title
< p> @ i.TourService_Description< / p>
价格:@ i.Price
< / div><! - imgInfo - >
< div class =os_form>
@ i.StartDate至@ i.EndDate
< span>< label>否。 of person< / label> @ Html.TextBoxFor(a => a [j] .PersonCnt,new {@class =personNo topInsideShadow numericOnly,@ maxlength =2})< / span>
< span>< label>检查以利用< / label> @ Html.CheckBoxFor(a => a [j] .IsSelected)< / span>
< / div><! - os-form - >
< / li>
j = j + 1;
}
}
< / ul>
< input type =submitvalue =submitclass =submitBtn/>
}

}



我得到的错误 -

using块缺少一个结束}字符。确保此块中的所有{字符都有匹配的}字符,并且没有任何}字符被解释为标记。

解决方案

我整理了你的代码:

 @ model List <   habg.models.otherservices  >  

@using(Html.BeginUmbracoForm < habg.pocos.otherservicessurfacecontroller > (otherservices))
{
@ Html.AntiForgeryToken()
if(Model!= null)
{
if(Model.Count> 0)
{
int j = 0;
foreach(var.in Model.FindAll(i => i.TourType == 1).ToList())
{
if(j == 0)
{
< h4 > 有组织的旅游< / h4 >
< ul class = os_list >
< li >
@ Html.HiddenFor(a => a [j] .TourServiceId)
@ Html.HiddenFor(a => a [j] .BookingId)
< div class = imgHolder > < img src = @ System.Web.Configuration.WebConfigurationManager.AppSettings [ adminproductimage_virtualpath = ] @ i.ImagePath / > < / div > <! - imgHolder - >
< div class = imgInfo > ;
@ i.TourService_Title
< p > @ i.TourService_Description < / p >
价格:@ i.Price
< / div > <! - imgInfo - >
< div class = os_form >
@ i.StartDate to @ i.EndDate
< span > < < span class =code-leadattribute> label > 否。人< / label > @ Html.TextBoxFor(a => a [j] .PersonCnt,new {@class =personNo topInsideShadow numericOnly,@ maxlength =2})< / span >
< span > < 标签 > 检查以获取< / label > @ Html.CheckBoxFor(a => a [j] .IsSelected)< / span >
< / div > <! - os-form - > ;
< / li >
j = j + 1;

< / ul >
}
< 输入 类型 = 提交 value = 提交 class = submitBtn / >
}
}
}
} < / habg.pocos.others ervicessurfacecontroller > < / habg。 models.otherservices >



你有太多的括号和太多的@符号


@model List<habg.Models.OtherServices>

@using (Html.BeginUmbracoForm<habg.pocos.OtherservicesSurfaceController>("otherservices"))
{
    @Html.AntiForgeryToken()
    if (Model!= null)
    {
        
        @if (Model != null && Model.Count > 0) 
        {
            int j=0;
            foreach(var i in Model.FindAll(i=>i.TourType == 1).ToList())
            {
                if(j==0)
                {
                    <h4>Organised Tour</h4>
                    <ul class="os_list">
                }
                <li>
                    @Html.HiddenFor(a => a[j].TourServiceId)
                    @Html.HiddenFor(a=>a[j].BookingId)
                    <div class="imgHolder"><img src="@System.Web.Configuration.WebConfigurationManager.AppSettings["AdminProductImage_VirtualPath"]@i.ImagePath" /></div><!--imgHolder-->
                    <div class="imgInfo">
                        @i.TourService_Title
                        <p>@i.TourService_Description</p>
                        Price : @i.Price
                    </div><!--imgInfo-->
                    <div class="os_form">
                        @i.StartDate to @i.EndDate
                        <span><label>No. of person</label>@Html.TextBoxFor(a => a[j].PersonCnt, new { @class = "personNo topInsideShadow numericOnly", @maxlength="2" })</span>
                        <span><label>Check to avail</label>@Html.CheckBoxFor(a=> a[j].IsSelected)</span>
                    </div><!--os-form-->
                </li>
                j = j + 1;
            }
         }
        </ul>
    <input type="submit" value="submit" class="submitBtn" />
    }
    
}


The error I am getting -
The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.

解决方案

I tidied up your code:

@model List<habg.models.otherservices>

@using (Html.BeginUmbracoForm<habg.pocos.otherservicessurfacecontroller>("otherservices"))
{
    @Html.AntiForgeryToken()
    if (Model!= null)
    {
        if (Model.Count > 0)
        {
            int j=0;
            foreach(var i in Model.FindAll(i=>i.TourType == 1).ToList())
            {
                if(j==0)
                {
                    <h4>Organised Tour</h4>
                    <ul class="os_list">                        
                        <li>
                            @Html.HiddenFor(a => a[j].TourServiceId)
                            @Html.HiddenFor(a=>a[j].BookingId)
                            <div class="imgHolder"><img src="@System.Web.Configuration.WebConfigurationManager.AppSettings[" adminproductimage_virtualpath="]@i.ImagePath" /></div><!--imgHolder-->
                            <div class="imgInfo">
                                @i.TourService_Title
                                <p>@i.TourService_Description</p>
                                Price : @i.Price
                            </div><!--imgInfo-->
                            <div class="os_form">
                                @i.StartDate to @i.EndDate
                                <span><label>No. of person</label>@Html.TextBoxFor(a => a[j].PersonCnt, new { @class = "personNo topInsideShadow numericOnly", @maxlength="2" })</span>
                                <span><label>Check to avail</label>@Html.CheckBoxFor(a=> a[j].IsSelected)</span>
                            </div><!--os-form-->
                        </li>
                        j = j + 1;

                    </ul>
                }
                    <input type="submit" value="submit" class="submitBtn" />
            }
        }
    }
}</habg.pocos.otherservicessurfacecontroller></habg.models.otherservices>


You had too many brackets and too many "@" symbols.


这篇关于MVC4视图中的错误(Razor)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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