在剃须刀中循环时出现编译错误
Compilation error whn loop in razor
我在下面的代码中遇到编译错误,它抱怨一个括号但是所有的括号和匹配我有点迷路有人可以在这里帮助我谢谢提前。
错误:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1513: } expected
@using System.Linq
@using System
@using System.Text
@using System.Collections;
@model List<PairingTest.Web.Models.QuestionnaireViewModel>
<html>
<head>
<title></title>
</head>
<body>
@using (Html.BeginForm("GetMarks","Questionnaire")) {
for(int i = 0;i < Model.Count;i++) {
<text> @Model[i].QuestionAsk </text> <br />
var s = @Model[i].PossibleAnswer;
string[] exAns = s.Split(',');
foreach( var singleAns in exAns){
<text>singleAns</text> <br />
@Html.RadioButtonFor(M =>M[i].UserAnsResponse, singleAns); <br />
}
<br />
}
<input type="submit" name="submit" />
}
</body>
你的错误是在s
变量的赋值上,请看下面修正的代码。您还有不必要的 <text>
标签和额外的分号。我建议您稍微阅读一下 Razor 语法。
@using System.Linq
@using System
@using System.Text
@using System.Collections;
@model List<PairingTest.Web.Models.QuestionnaireViewModel>
<html>
<head>
<title></title>
</head>
<body>
@using (Html.BeginForm("GetMarks","Questionnaire")) {
for(int i = 0;i < Model.Count;i++) {
@Model[i].QuestionAsk <br />
var s = Model[i].PossibleAnswer;
string[] exAns = s.Split(',');
foreach( var singleAns in exAns){
@singleAns <br />
@Html.RadioButtonFor(M =>M[i].UserAnsResponse, singleAns) <br />
}
<br />
}
<input type="submit" name="submit" />
}
</body>
我在下面的代码中遇到编译错误,它抱怨一个括号但是所有的括号和匹配我有点迷路有人可以在这里帮助我谢谢提前。
错误:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1513: } expected
@using System.Linq
@using System
@using System.Text
@using System.Collections;
@model List<PairingTest.Web.Models.QuestionnaireViewModel>
<html>
<head>
<title></title>
</head>
<body>
@using (Html.BeginForm("GetMarks","Questionnaire")) {
for(int i = 0;i < Model.Count;i++) {
<text> @Model[i].QuestionAsk </text> <br />
var s = @Model[i].PossibleAnswer;
string[] exAns = s.Split(',');
foreach( var singleAns in exAns){
<text>singleAns</text> <br />
@Html.RadioButtonFor(M =>M[i].UserAnsResponse, singleAns); <br />
}
<br />
}
<input type="submit" name="submit" />
}
</body>
你的错误是在s
变量的赋值上,请看下面修正的代码。您还有不必要的 <text>
标签和额外的分号。我建议您稍微阅读一下 Razor 语法。
@using System.Linq
@using System
@using System.Text
@using System.Collections;
@model List<PairingTest.Web.Models.QuestionnaireViewModel>
<html>
<head>
<title></title>
</head>
<body>
@using (Html.BeginForm("GetMarks","Questionnaire")) {
for(int i = 0;i < Model.Count;i++) {
@Model[i].QuestionAsk <br />
var s = Model[i].PossibleAnswer;
string[] exAns = s.Split(',');
foreach( var singleAns in exAns){
@singleAns <br />
@Html.RadioButtonFor(M =>M[i].UserAnsResponse, singleAns) <br />
}
<br />
}
<input type="submit" name="submit" />
}
</body>