Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 预期a";{but find a";)";。块语句必须包含在Asp.NETMVC5中的";{quot;和";}";中_C#_Razor_Asp.net Mvc 5 - Fatal编程技术网

C# 预期a";{but find a";)";。块语句必须包含在Asp.NETMVC5中的";{quot;和";}";中

C# 预期a";{but find a";)";。块语句必须包含在Asp.NETMVC5中的";{quot;和";}";中,c#,razor,asp.net-mvc-5,C#,Razor,Asp.net Mvc 5,竞赛M->模型属性 public SelectList EmployeeList { get; set; } public int EmployeeId { get; set; } 控制器动作 在主视图中单击按钮时,将点击此操作,在处理数据库中的下拉数据后,我将值分配给下拉对象,并尝试在局部视图中显示该值 public ActionResult AssignContest() { try {

竞赛M->模型属性

public SelectList EmployeeList { get; set; }
public int EmployeeId { get; set; }
控制器动作
在主视图中单击按钮时,将点击此操作,在处理数据库中的下拉数据后,我将值分配给下拉对象,并尝试在局部视图中显示该值

public ActionResult AssignContest()
        {
            try
                {
                int id = 3;
                var res = ContestVM.getTLEmployees(id).ToList();
                var eList = new ContestM();
                eList.EmployeeList = new SelectList(res, "EmployeeId", "FirstName");
                return PartialView("Assign", new ContestM() { EmployeeList = eList.EmployeeList });
                }
                catch (Exception ex)
                {
                    ViewData["error"] = ex.Message.ToString();
                    return View("~/Views/Shared/LogoutOrInvalid.cshtml");
                }
        }
我的剃须刀视图(assign.cshtml)

@model Performance.Launcher.Models.m
@使用(Html.BeginForm(“AssignContest”,“Contest”,FormMethod.Post,new{id=“frmContestAssignContest”})))
{
//var EmployistData=ViewData[“employeesList”];
@Html.AntiForgeryToken()
竞赛

@Html.ValidationSummary(true) @Html.HiddenFor(model=>model.contesticId) @LabelFor(model=>model.EmployeeId,新的{@class=“controllabel col-md-2”}) @DropDownListFor(model=>model.EmployeeId,model.employeedeet,“选择…”,新的{htmlAttributes=new{@class=“form control col-md-2”}) //@Html.DropDownList(“dropdown1”,ViewData[“employeesList”]) //@Html.ValidationMessageFor(model=>model.EmployeeId) }

无法找到我的错误所在。非常感谢您的帮助。

这行末尾似乎有一个额外的

@using (Html.BeginForm("AssignContest", "Contest", FormMethod.Post, new { id = "frmContestAssignContest" })))

顺便说一句,如果你想知道我是怎么这么快就明白的,我只是用我的浏览器的“查找”和“搜索”),直到我找到了一个不匹配的(“在它之前,它就在
{
,所以我知道这就是问题所在。你应该记录错误消息的含义;很多时候,它们都非常清楚和有用。

异常到底发生在哪里?
@使用(Html.BeginForm(“AssignContest”,“Contest”,FormMethod.Post,new{id=“frmContestAssignContest”})
您在末端放置了一个额外的支架,请将其拆下
@using (Html.BeginForm("AssignContest", "Contest", FormMethod.Post, new { id = "frmContestAssignContest" })))