且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MVC4视图中的错误(Razor)

更新时间:2022-11-07 23:34:26

我整理了你的代码:

 @ 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 &gt ;
@ i.TourService_Title
< p > @ i.TourService_Description < / p >
价格:@ i.Price
< / div > <! - imgInfo - >
< div class = os_form >
@ i.StartDate to @ i.EndDate
< span > < 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 - &gt ;
< / 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.