Hecatonchires February 2016

Syntax error in temporary build file

I'm building a fairly standard razor/c# page for an internal website. Its basically a wrapper around a query that provides valid arguments for a db query.

The page is generating an error in Asp_Web_?????.cshtml when built. For the life of me I cannot find the error. Included below is the source of the page

@{
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "ABC Floor Limits";
}

<hgroup class="title">
    <h1>@Page.Title.</h1>
    <h2>Adjust.</h2>
</hgroup>


@{
    var DbCustom = Database.Open("Online_Ctrack6_Custom");
    var DbCustLogs = Database.Open("Online_CustLogs");

    int vehicleId = -1;
    string currentAction;

    if(IsPost)
    {
        vehicleId = Request.Form["vehicleId"].AsInt();
        string applianceName = Request.Form["applianceName"];
        int floorHours = Request.Form["hours"].AsInt();
        DateTime? dateToParse;
        DateTime dateTaken;
        string result = "";


        if (string.IsNullOrEmpty(Request.Form["dateTaken"]) == false)
        {
            var dtValue = new DateTime();
            if (DateTime.TryParse(Request.Form["dateTaken"], out dtValue))
            {
                dateToParse = dtValue;
            }
            else
            {
                dateToParse = null;
            }
        }
        else
        {
            dateToParse = null;
        }

        currentAction = Request.Form["action"];
        if (currentAction == "updateHours")
        {
            try
            {
                dateTaken = (DateTime)dateToParse;
                result = doProcessHoursForm(DbCustLogs, vehicleId, applianceName, dateTaken, floorHours);
            }
            catch (InvalidDataException ex)
            {
                @:<div class="error">@ex.Message</div>
            }
            catch (ArgumentNullException ex)
            {
                @:<div class="error">@ex.ParamName cannot be null.<br />@ex.Me        

Answers


Andrew February 2016

It is because you are missing the @functions keyword in the section where you are declaring the methods.

Post Status

Asked in February 2016
Viewed 1,048 times
Voted 12
Answered 1 times

Search




Leave an answer