我试图在Razor中用foreach和switch重新创建它并遇到困难。似乎打开和关闭DIV会导致Razor出现问题
代码并且它一直表示我在}
上没有结束foreach (var questionBasicSection in Model.ToList())
或者在最后一种情况下</div>
没有匹配的开始标记。
我尝试在<text></text>
标记周围使用<div class="row mt5"> <!-- @question.QUESTION -->
标记,但无法使用它
围绕`标签。
关于如何实现这一点的任何想法? 因为这些部分不同,所以必须以这种方式格式化......
这是所需的HTML输出:
<div class="row mt5"> <!-- Personnel -->
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">a. Personnel</label>
</div>
<div class="col-md-2">
</div>
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[0].AnswerFloatString" class="form-control currencyMask amt" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="currency" id="Personnel_Amount_Budgeted" type="text" value="" />
<input type="hidden" name="QuestionBasicSection.Questions[0].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[0].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[0].ID" id="QuestionBasicSection.Questions[0].ID" value="200" />
<input type="hidden" name="QuestionBasicSection.Questions[0].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[0].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[0].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[0].QUESTION_SECTION_ID" value="9" />
</div>
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[1].AnswerFloatString" class="form-control percentMask" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="percent" id="Personnel_Amount_Budgeted_Pct" type="text" value="" disabled />
<input type="hidden" name="QuestionBasicSection.Questions[1].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[1].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[1].ID" id="QuestionBasicSection.Questions[1].ID" value="201" />
<input type="hidden" name="QuestionBasicSection.Questions[1].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[1].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[1].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[1].QUESTION_SECTION_ID" value="9" />
</div>
</div>
<div class="row mt5"> <!-- Equipment -->
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[2].AnswerFloatString" class="form-control currencyMask amt" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="currency" id="Fringe_Benefits_Budgeted" type="text" value="" />
<input type="hidden" name="QuestionBasicSection.Questions[2].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[2].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[2].ID" id="QuestionBasicSection.Questions[2].ID" value="202" />
<input type="hidden" name="QuestionBasicSection.Questions[2].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[2].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[2].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[2].QUESTION_SECTION_ID" value="9" />
</div>
<div class="col-md-2">
<input name="QuestionBasicSection.Questions[3].AnswerFloatString" class="form-control percentMask_2" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="percent" id="Fringe_Benefits_Pct" type="text" value="" disabled />
<input type="hidden" name="QuestionBasicSection.Questions[3].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[3].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[3].ID" id="QuestionBasicSection.Questions[3].ID" value="203" />
<input type="hidden" name="QuestionBasicSection.Questions[3].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[3].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[3].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[3].QUESTION_SECTION_ID" value="9" />
</div>
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[4].AnswerFloatString" class="form-control percentMask" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="currency" id="Fringe_Benefits_Budgeted_Pct" type="text" value="" disabled />
<input type="hidden" name="QuestionBasicSection.Questions[4].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[4].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[4].ID" id="QuestionBasicSection.Questions[4].ID" value="204" />
<input type="hidden" name="QuestionBasicSection.Questions[4].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[4].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[4].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[4].QUESTION_SECTION_ID" value="9" />
</div>
</div>
<div class="row mt5"> <!-- Travel-->
<div class="col-md-2">
</div>
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[5].AnswerFloatString" class="form-control currencyMask amt" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="currency" id="Travel_Budgeted" type="text" value="" />
<input type="hidden" name="QuestionBasicSection.Questions[5].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[5].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[5].ID" id="QuestionBasicSection.Questions[5].ID" value="205" />
<input type="hidden" name="QuestionBasicSection.Questions[5].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[5].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[5].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[5].QUESTION_SECTION_ID" value="9" />
</div>
<div class="col-md-3">
<input name="QuestionBasicSection.Questions[6].AnswerFloatString" class="form-control percentMask" data-bind="textInput: sdto.DATE_INACTIVE"
data-pattern="percent" id="Travel_Budgeted_Pct" type="text" value="" disabled />
<input type="hidden" name="QuestionBasicSection.Questions[6].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[6].ANSWER_DATA_TYPE" value="4" />
<input type="hidden" name="QuestionBasicSection.Questions[6].ID" id="QuestionBasicSection.Questions[6].ID" value="206" />
<input type="hidden" name="QuestionBasicSection.Questions[6].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[6].IS_MULTI_ANSWER" value="False" />
<input type="hidden" name="QuestionBasicSection.Questions[6].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[6].QUESTION_SECTION_ID" value="9" />
</div>
</div>
这是Razor代码:
@foreach (var questionBasicSection in Model.ToList())
{
@* doing some other stuff here *@
foreach (var question in questionBasicSection.Questions)
{
var QuestionTitle = (question.DISPLAY_NAME != null?question.DISPLAY_NAME + " " + question.QUESTION: question.QUESTION);
switch (question.QuestionIndex)
{
case 200:
<text><div class="row mt5"> <!-- @question.QUESTION --></text>
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-2">
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 201:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
</div>
break;
case 202:
<text><div class="row mt5"> <!-- @question.QUESTION --></text>
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 203:
<div class="col-md-2">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 204:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
</div>
break;
case 205:
<text><div class="row mt5"> <!-- @question.QUESTION --></text>
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-2">
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 206:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
</div>
break;
}
}
}
答案 0 :(得分:1)
更容易在代码中显示:
@foreach (var questionBasicSection in Model.ToList())
{
// New section start
<div class="row mt5"><span>@question.QUESTION</span>
@* doing some other stuff here *@
foreach (var question in questionBasicSection.Questions)
{
var QuestionTitle = (question.DISPLAY_NAME != null?question.DISPLAY_NAME + " " + question.QUESTION: question.QUESTION);
switch (question.QuestionIndex)
{
case 200:
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-2">
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 201:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 202:
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 203:
<div class="col-md-2">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 204:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 205:
<div class="col-md-4">
<label class="control-label col-med-6" for="QuestionBasicSection.Questions[0].ANSWER_FLOAT">@QuestionTitle/label>
</div>
<div class="col-md-2">
</div>
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth currencyMask amt",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
case 206:
<div class="col-md-3">
@Html.TextBoxFor(q => question.AnswerFloatString, (object)new { disabled = "disabled" } : new { id=question.QUESTION.Replace(' ', '_').Replace(".", String.Empty).Replace("=", String.Empty),
name = "QuestionBasicSection.Questions[" + question.Index + "].AnswerFloatString", @class = "form-control floatwidth percentMask",
data_bind = "textInput: sdto.DATE_INACTIVE", data_pattern = question.FORMAT_VALIDATION })
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" id="QuestionBasicSection.Questions[@question.Index].ANSWER_DATA_TYPE" value="@question.ANSWER_DATA_TYPE" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].ID" id="QuestionBasicSection.Questions[@question.Index].ID" value="@question.ID" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" id="QuestionBasicSection.Questions[@question.Index].IS_MULTI_ANSWER" value="@question.IS_MULTI_ANSWER.ToString()" />
<input type="hidden" name="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" id="QuestionBasicSection.Questions[@question.Index].QUESTION_SECTION_ID" value="@question.QUESTION_SECTION_ID.ToString()" />
</div>
break;
} // end of questions for section
} //end of section
// Section end
</div>
}
答案 1 :(得分:0)
您可以对每行部分HTML代码使用 android:setvisibility="gone"
语法:
@:
但是,当启用自动粘贴功能时,我仍然遇到此问题。当Razor重新评估整个视图时,通常会使用不正确的缩进来填充所有内容,而不是像它应该那样打破线条。
您最安全的选择可能是使用@if (foo)
{
@:</div>
}
:
Html.Raw
现在,它甚至不再是HTML代码了。它只是一个字符串,所以Razor会完全忽略它。