使用局部变量在aspx视图引擎中进行字符串连接。不是Razor mvc观点

时间:2016-10-07 04:20:39

标签: asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-4

如何在ASPX视图引擎中串联连接? 我想在动态生成id时使用我的变量(在下面的示例中,允许添加多个教育详细信息)。我想用id计数替换(<%=CurrentEducation%>)。我可以在Razor中轻松完成此操作,但不能在aspx视图中执行此操作。你能否指出&lt; %%&gt;的语法声明?在aspx视图引擎中的东西好吗?我只能在剃刀示例中找到示例。

<% dim currentEducation = 1 %>
<% for each item As EducationDetailsViewModel in Model.EducationDetails %>
<div class="row">
    <div class="col-md-11">
        <div class="row">
            <div class="col-md-3">
                <%= Html.LabelFor(Function(x) item.Educationlevel, New With {.class = "control-label" + "test", .id="EducationDetails_(<%=CurrentEducation%>)_EducationLevel"})%><span class="text-danger">*</span>
                <%= Html.TextBoxFor(Function(x) item.Educationlevel,New With{.class="form-control"})%>
            </div>
            <div class="col-md-4">
                <%= Html.LabelFor(Function(x) item.SchoolName, New With {.class = "control-label"})%><span class="text-danger">*</span>
                <%= Html.TextBoxFor(Function(x) item.SchoolName,New With{.class="form-control"})%>
            </div>
            <div class="col-md-3">
                <%= Html.LabelFor(Function(x) item.YearsAttended, New With {.class = "control-label"})%>
                <%= Html.TextBoxFor(Function(x) item.YearsAttended,New With{.class="form-control"})%>
            </div>
            <div class="col-md-2">
                <%= Html.LabelFor(Function(x) item.IsGraduated, New With {.class = "control-label"})%>
                <%= Html.RadioButtonFor(Function(x) item.isGraduated, False, new with {.style="width:auto"})%>No:
                <%= Html.RadioButtonFor(Function(x) item.isGraduated, True, new with {.style="width:auto"})%>Yes:
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <%= Html.LabelFor(Function(x) item.AreaOfStudy, New With {.class = "control-label"})%>
                <div class="">
                    <%= Html.TextBoxFor(Function(x) item.AreaOfStudy,New With{.class="form-control"})%>
                </div>
            </div>
        </div>
        <br />
    </div>
    <div class="col-md-1">
        <span class="text-danger">X</span>
    </div>
</div>
<% currentEducation = currentEducation + 1 %>
<% next %>

0 个答案:

没有答案