Home C# ASP .NET cshtml: CS1513: } expected
Reply: 0

C# ASP .NET cshtml: CS1513: } expected

Orlando
1#
Orlando Published in 2018-01-12 15:28:03Z

I´m working on a web project that uses C# ASP .NET and I get an CS1513: } expected error from one view. I can´t find any missing curly braces, semicolons or any other syntactical errors. Even checked the { and } count in word, both the same. Would appreciate it if somebody could help.

My View.cshtml:

@using Nop.Plugin.Misc.ThonyoPDFCatalog.Infrastructure.DataStructures
@using Nop.Web.Framework.UI
@model Nop.Plugin.Misc.ThonyoPDFCatalog.ViewData.PdfAnimalCatalogModel

@{
    //page title
    ViewBag.Title = Model.Title;
}

@{
    decimal exactRequiredPages = Model.Animals.Count / 2;
    int pageCount = Convert.ToInt32(Math.Ceiling(exactRequiredPages));
    int lastAnimalPrinted = -1;
    const int animalsPerPage = 2;

    for (int currentPage = 0; currentPage < pageCount; currentPage++) //Print pages
    {
        <div class="pdfPageWrapper @{if(currentPage == pageCount - 1) { Html.Encode("lastPage"); }}">
            @{
                for (int currentAnimalIndex = lastAnimalPrinted + 1; currentAnimalIndex <= lastAnimalPrinted + animalsPerPage; currentAnimalIndex++) //Print two animals
                {
                    if (currentAnimalIndex <= Model.Animals.Count - 1) //Check if animal index is not out of list boundaries
                    {
                        Animal currentAnimal = @Model.Animals[currentAnimalIndex];
                        //Set display values
                        string fishImageUrl = "";
                        if (currentAnimal.PictureUrl != null)
                        {
                            fishImageUrl = currentAnimal.PictureUrl;
                        }

                        string latFishName = "";
                        if (currentAnimal.LatName != null)
                        {
                            latFishName = currentAnimal.LatName;
                        }

                        string fishName = "";
                        if (currentAnimal.Name != null)
                        {
                            fishName = currentAnimal.Name;
                        }

                        string price = "";
                        if (currentAnimal.Price != null)
                        {
                            price = currentAnimal.Price.Text;
                        }

                        string lengthText = "";
                        if (currentAnimal.Length != null)
                        {
                            lengthText = currentAnimal.Length.Text;
                        }

                        string aquariumSizeText = "";
                        if (currentAnimal.AquariumSize != null)
                        {
                            aquariumSizeText = currentAnimal.AquariumSize.Text;
                        }

                        string temperatureText = "";
                        if (currentAnimal.Temperature != null)
                        {
                            temperatureText = currentAnimal.Temperature.Text;
                        }

                        GroupBehaviour.GroupBehaviourType behaviour = null;
                        if (currentAnimal.GroupBehaviour != null)
                        {
                            behaviour = currentAnimal.GroupBehaviour.Behaviour;
                        }

                        AquariumPosition.AquariumPositionType aquariumPosition = null;
                        if (currentAnimal.AquariumPosition != null)
                        {
                            aquariumPosition = currentAnimal.AquariumPosition.Position;
                        }

                        string difficultyText = "";
                        if (currentAnimal.Difficulty != null)
                        {
                            difficultyText = currentAnimal.Difficulty.Text;
                        }

                        string barcodePath = "";
                        string barcodeText = "";
                        if (currentAnimal.BarcodeFile != null)
                        {
                            barcodePath = currentAnimal.BarcodeFile.FilePath;
                            barcodeText = currentAnimal.BarcodeFile.ThonyoBarcode.Value;
                        }

                        <div class="animalWrapper">
                            <div class="fishPanel">
                                <div class="imageColumn">
                                    <img src=@fishImageUrl class="fishImage" alt="">
                                    <div class="fishNamePanel">
                                        <div class="latFishName">@latFishName</div>
                                        <div>@fishName</div>
                                        <div class="priceText">@price</div>
                                    </div>
                                </div>
                                <div class="informationColumn">
                                    <div class="informationItem">
                                        <img width="60px" height="89px" src="/Content/Images/AnimalCatalog/animalLength.png" alt="">
                                        <div class="sizeTextWrapper">
                                            <text>@lengthText</text>
                                        </div>
                                    </div>
                                    <div class="informationItem reqWaterItem">
                                        <span class="aquariumImageCenterHelper"></span>
                                        <img class="aquariumImage" width="100px" height="62px" src="/Content/Images/AnimalCatalog/aquarium.png" alt="" />
                                        <div class="reqWaterTextWrapper">
                                            <text>@aquariumSizeText</text>
                                        </div>
                                    </div>
                                    <div class="informationItem">
                                        <div class="thermometerColumn">
                                            <span class="thermometerImageCenterHelper"></span>
                                            <img class="thermometerImage" width="25px" src="/Content/Images/AnimalCatalog/thermometer.png" alt="" />
                                        </div>
                                        <div class="verticalCenter temperatureColumn">
                                            <text class="temperatureText">@temperatureText</text>
                                        </div>
                                    </div>
                                    <div class="informationItem">
                                        <span class="groupImageCenterHelper"></span>
                                        @GetGroupImage(behaviour)
                                    </div>
                                    <div class="informationItem positionItem">
                                        <span class="positionImageCenterHelper"></span>
                                        @GetPositionImage(aquariumPosition)
                                    </div>
                                    <div class="informationItem">
                                        <div class="verticalCenter">
                                            <text class="difficulty">Anspruchsvoll</text>
                                            <text class="difficultyText">@difficultyText</text>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="barcodePanel">
                                <div class="barcodeWrapper">
                                    <img src="@barcodePath" width="400px" height="80px" alt="">
                                    <text class="barcodeText">@barcodeText</text>
                                </div>
                            </div>
                        </div>

                        bool isFirstPageItem = currentAnimalIndex % 2 == 0;
                        if (isFirstPageItem)
                        {
                            <div class="panelSeperator"></div>
                        }
                    }
                }

            lastAnimalPrinted += 2;
            }
        </div>
    }
}

@helper GetGroupImage(GroupBehaviour.GroupBehaviourType behaviour)
{
string einzerlgängerImagePath = "/Content/Images/AnimalCatalog/GroupBehaviours/einzelgänger.png";
string paarImagePath = "/Content/Images/AnimalCatalog/GroupBehaviours/paarhaltung.png";
string gruppeImagePath = "/Content/Images/AnimalCatalog/GroupBehaviours/einzelGruppe.png";
string schwarmImagePath = "/Content/Images/AnimalCatalog/GroupBehaviours/schwarmfisch.png";

string imagePath = "";

switch (behaviour)
{
    case (GroupBehaviour.GroupBehaviourType.EINZELGÄNGER):
        imagePath = einzerlgängerImagePath;
        break;
    case (GroupBehaviour.GroupBehaviourType.PAAR):
        imagePath = paarImagePath;
        break;
    case (GroupBehaviour.GroupBehaviourType.GRUPPE):
        imagePath = gruppeImagePath;
        break;
    case (GroupBehaviour.GroupBehaviourType.SCHWARM):
        imagePath = schwarmImagePath;
        break;
    default:
        break;
}

    <img class="groupImage" width="80px" height="61px" src="@imagePath" alt="" />
}

@helper GetPositionImage(AquariumPosition.AquariumPositionType aquariumPosition)
{
string obenImagePath = "/Content/Images/AnimalCatalog/AquariumPositions/fischOben.png";
string mitteImagePath = "/Content/Images/AnimalCatalog/AquariumPositions/fischMitte.png";
string untenImagePath = "/Content/Images/AnimalCatalog/AquariumPositions/fischUnten.png";

string imagePath = "";

switch (aquariumPosition)
{
    case (AquariumPosition.AquariumPositionType.OBERFLÄCHE):
        imagePath = obenImagePath;
        break;
    case (AquariumPosition.AquariumPositionType.MITTE):
        imagePath = mitteImagePath;
        break;
    case (AquariumPosition.AquariumPositionType.GRUND):
        imagePath = untenImagePath;
        break;
    default:
        break;
}

    <img class="positionImage" width="102px" height="84 px" src="@imagePath" alt="" />
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.331267 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO