我更改为 HTML 5,突然出现了一个以前没有的错误。错误信息是:
验证 (HTML5):元素 tr' 的开始标签和结束标签之间不允许出现文本。
我没有看到任何纯文本,当我尝试将 @: 更改为 @ 或删除它时,我收到一条消息,上面写着“没有开始标签的结束标签”。我没有看到我在哪里输入了任何文本。请帮忙。
<tr id="listTableRow">
@{
int cnt = 0;
List<SchoolIn.ViewModels.EnrolledCourseData> courses = ViewBag.Courses;
List<String> dayofclass = ViewBag.classDay;
List<String> theListOfTeachers = ViewBag.teacherList;
List<String> teacher = ViewBag.instructors;
List<SchoolIn.Models.Enrollment> LoDays = ViewBag.lDays;
List<String> listofinstructors = ViewBag.listOfInstructors;
List<int> coursesIds = new List<int>();
foreach (var course in courses.Select((x, i) => new { Data = x, Index = i }))
{
int currentIndex = course.Index;
String selectedday = "";
String selectedteacher = "";
if (cnt++ % 4 == 0)
{
@: </tr> <tr>
}
嗨 CoderOll,感谢您帮助我。您的建议是第一个标签的解决方案,但我粘贴在下面的第二个标签似乎仍然认为之间存在文本,即使我有如下所示。我研究了 Razor 显式代码块,发现了有关包装模棱两可的代码语句的信息,例如……</p>
@foreach(var item in order.Items){
Var itemName-(GetOrderItemName<string>(item)):
<li>@itemName</li>…
但我找不到 Razor 可能误认为 和 之间的标记的任何代码。我什至尝试用 < 和 > 替换 < 和 > 但这不起作用。您有什么想法可以将代码的哪一部分作为文本插入?
感谢你的帮助。
<tr>
}
@: <td id="days" >
<input type="checkbox" id="checkbox" name="selectedCourses" value="@course.Data.CourseID" @(Html.Raw(course.Data.Assigned ? "checked=\"checked\"" : ""))/>
@course.Data.Title @: <br />
if (dayofclass != null && course.Index < dayofclass.Count())
{
String sellectedDay = dayofclass.ElementAt(course.Index);
selectedday = sellectedDay;
if (theListOfTeachers != null && course.Index < theListOfTeachers.Count())
{
String selectedTeacher = theListOfTeachers.ElementAt(course.Index);
selectedteacher = selectedTeacher;
}
}
if (selectedday == "")
{
@Html.DropDownList("searchString", Model.WeekDays.Select(s => new SelectListItem { Text = s.ToString(), Value = s.ToString(), Selected = s.ToString().Equals("Day") }), new { @class = "daylists" })
@Html.DropDownList("instructorString", listofinstructors.Select(tch => new SelectListItem { Text = tch.ToString(), Value = tch.ToString(), Selected = tch.ToString().Equals("Pick One") }), new { @class = "teacherlists" })
}
else
if (Model.Enrollments != null)
{
@Html.DropDownList("searchString", Model.Enrollments.FirstOrDefault().WeekDays.Select(s => new SelectListItem { Text = s.ToString(), Value = s.ToString(), Selected = s.ToString().Equals(selectedday) }), new { @class = "daylists" })
@Html.DropDownList("instructorString", listofinstructors.Select(tch => new SelectListItem { Text = tch.ToString(), Value = tch.ToString(), Selected = tch.ToString().Equals(selectedteacher) }), new { @class = "teacherlists" })
}
@:</td>
}
@:</tr>