在我的共享 _Layout.cshtml 视图中,我有一个隐藏字段,我想保留一个值以在多个页面中使用。现在在其中一个页面中,我必须提交一个需要该特定隐藏字段值的表单。我在想我所需要的只是从我的 _Layout.cshtml 传入 hiddenfield 值,但不知道如何分配它,下面的工作但我正在创建一个额外的 hiddenfield 并使用来自的 hiddenfield 值分配它的值我的_Layout.cshtml。
是否可以消除额外隐藏字段的使用?
谢谢。
<script type="text/javascript">
($('#p1').val($('#playerChoice_1').val()));
</script>
@using (Ajax.BeginForm(new AjaxOptions { OnSuccess = "LoadThankYou()" }))
{
@Html.ValidationSummary(true)
<fieldset >
<div style="FILTER:" class="fb-grouplabel fb-item fb-100-item-column">
@Html.LabelFor(model => model.Name)
</div>
<div class="fb-input-box editor-field">
@* <input id="item7_text_1" class="" name="text7" maxlength="254" placeholder="Enter your name"
autocomplete="off" data-hint="" type="text" />*@
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div style="FILTER:" class="fb-grouplabel fb-item fb-100-item-column">
@Html.LabelFor(model => model.Email)
</div>
<div class="fb-input-box editor-field">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<div style="FILTER:" class="fb-grouplabel fb-item fb-100-item-column">
@Html.LabelFor(model => model.Contact)
</div>
<div class="fb-input-box editor-field">
@Html.EditorFor(model => model.Contact)
@Html.ValidationMessageFor(model => model.Contact)
</div>
<div style="FILTER:" class="fb-grouplabel fb-item fb-100-item-column">
@Html.LabelFor(model => model.PersonalID)
</div>
<div class="fb-input-box editor-field">
@Html.EditorFor(model => model.PersonalID)
@Html.ValidationMessageFor(model => model.PersonalID)
</div>
<input type="hidden" id="p1" name="Choice_1" />
<div style="MIN-HEIGHT: 1px" id="fb-submit-button-div" class="fb-item-alignment-left fb-footer">
@* <input style="BACKGROUND-IMAGE: url(theme/default/images/btn_submit.png)"
id="fb-submit-button" class="fb-button-special" type="submit" value="Submit" />*@
<input type="submit" value="Submit" />
</div>
</fieldset>
}