Asp.net mvc 如何将下拉列表的选定值从一个视图发送到另一个视图?
我试图设置从一个视图到另一个视图的下拉列表值。即使两个视图具有相同的模型,我也没有得到它 我的第一个视图是,我想从中发送值Asp.net mvc 如何将下拉列表的选定值从一个视图发送到另一个视图?,asp.net-mvc,Asp.net Mvc,我试图设置从一个视图到另一个视图的下拉列表值。即使两个视图具有相同的模型,我也没有得到它 我的第一个视图是,我想从中发送值 @using (Html.BeginForm("ApplicantDetails", "Applicant", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) { @H
@using (Html.BeginForm("ApplicantDetails", "Applicant", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<section class="form-horizontal">
<h4>Applicant Detail</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(m => m.Salutation, new { @class = "control-label col-md-2" })
<div class="col-xs-2 salutation">
@Html.DropDownListFor(m => m.Salutation, Model.Salutation, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Salutation, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.FirstName, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.FirstName, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.FirstName,null,new {@class = "text-warning"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Surname, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.Surname, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Surname, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOB, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.DOB, new {Id = "datepicker", @class = "form-control calender" })
@Html.ValidationMessageFor(model => model.DOB, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Email, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CountryofResidence, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.CountryofResidence, new { Id = "countryofresidence", @class = "form-control"})
@Html.ValidationMessageFor(model => model.CountryofResidence, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CountryofNationality, new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.TextBoxFor(model => model.CountryofNationality, new { Id = "countryofnationality", @class = "form-control" })
@Html.ValidationMessageFor(model => model.CountryofNationality, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Currency, new { @class = "control-label col-md-2" })
<div class="col-md-2">
@Html.DropDownListFor(m => m.Currency, Model.Currency, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Currency, null, new { @class = "text-warning" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Go" class="btn btn-primary" />
</div>
</div>
</section>
}
</div>
@使用(Html.BeginForm(“applicationDetails”,“applicator”,new{ReturnUrl=ViewBag.ReturnUrl},FormMethod.Post,new{@class=“form horizontal”,role=“form”}))
{
@Html.AntiForgeryToken()
申请人详情
@Html.ValidationSummary(true)
@LabelFor(m=>m.sallation,新的{@class=“controllabel col-md-2”})
@DropDownListFor(m=>m.sallation,Model.sallation,new{@class=“form control”})
@Html.ValidationMessageFor(m=>m.sallation,null,new{@class=“text warning”})
@LabelFor(model=>model.FirstName,新的{@class=“controllabel col-md-2”})
@Html.TextBoxFor(model=>model.FirstName,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.FirstName,null,new{@class=“text warning”})
@Html.LabelFor(model=>model.姓氏,新的{@class=“controllabel col-md-2”})
@Html.TextBoxFor(model=>model.namname,new{@class=“form control”})
@Html.ValidationMessageFor(model=>model.namname,null,new{@class=“text warning”})
@LabelFor(model=>model.DOB,新的{@class=“controllabel col-md-2”})
@TextBoxFor(model=>model.DOB,新的{Id=“datepicker”,@class=“form control calendar”})
@ValidationMessageFor(model=>model.DOB,null,新的{@class=“text warning”})
@Html.LabelFor(model=>model.Email,新的{@class=“controllabel col-md-2”})
@Html.TextBoxFor(model=>model.Email,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Email,null,新{@class=“text warning”})
@LabelFor(model=>model.CountryofResidence,新的{@class=“controllabel col-md-2”})
@TextBoxFor(model=>model.CountryofResidence,新的{Id=“CountryofResidence”,@class=“form control”})
@Html.ValidationMessageFor(model=>model.CountryofResidence,null,new{@class=“text warning”})
@Html.LabelFor(model=>model.CountryofNationality,新的{@class=“controllabel col-md-2”})
@TextBoxFor(model=>model.CountryofNationality,新的{Id=“CountryofNationality”,@class=“formcontrol”})
@Html.ValidationMessageFor(model=>model.CountryofNationality,null,new{@class=“text warning”})
@LabelFor(m=>m.Currency,新的{@class=“controllabel col-md-2”})
@DropDownListFor(m=>m.Currency,Model.Currency,new{@class=“form control”})
@Html.ValidationMessageFor(m=>m.Currency,null,new{@class=“text warning”})
}
我的第二个视图是,我想在其中显示值,在“敬礼”文本框中,我想获得第一个视图“敬礼”选择值
<div class="row row-placing">
@using (Html.BeginForm("Compare", "Quote", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<section class="form-horizontal form-horizontal-placing">
<div class="form-group table-formgroup">
<table class="table table-striped table-layout" id="table-dynamic">
<thead>
<tr class="success">
<th>#</th>
<th>First Name</th>
<th>SurName</th>
<th>Date Of Birth</th>
<th>Email</th>
<th class="table-heading-phone">Phone Number</th>
<th></th>
</tr>
</thead>
<tbody>
<tr id="row1">
<td>
<span>1</span>
@Html.TextBox("Salutation", new { @Value = "");
</td>
<td>
@Html.TextBoxFor(m => m.FirstName, new {@Value = Model.FirstName, @class = "form-control" })
@Html.ValidationMessageFor(m => m.FirstName)
</td>
<td>
@Html.TextBoxFor(m => m.Surname, new {@Value = Model.Surname, @class = "form-control " })
@Html.ValidationMessageFor(m => m.Surname)
</td>
<td>
@Html.TextBoxFor(m => m.DOB, new {@Value = Model.DOB, @class = "form-control" })
@Html.ValidationMessageFor(m => m.DOB)
</td>
<td>
@Html.TextBoxFor(m => m.Email, new {@Value = Model.Email, @class = "form-control" })
@Html.ValidationMessageFor(m => m.Email)
</td>
<td>
@Html.DropDownListFor(m => m.Extensions, Model.Extensions, "Ext", new { @class = "form-control ext0" })
@Html.ValidationMessageFor(m => m.Extensions)
</td>
<td>
@Html.TextBoxFor(m => m.PhoneNumber, new { @class = "form-control phonenumber0" })
@Html.ValidationMessageFor(m => m.PhoneNumber)
</td>
</tr>
<tr id="row2"></tr>
</tbody>
</table>
<div class="depedent">
<ul>
<li class="col-md-2 ">
<label class="control-label">Enter Dependent</label>
</li>
<li class="col-md-3">
<input type="text" name="numberofdependent" class="form-control numberofdepedentextbox " />
</li>
<li class="col-md-2">
<input type="button" name="AddChild" value="Add Dependents" class="btn btn-primary btn-click" />
</li>
<li class="col-md-2">
<input type="button" name="SaveDependent" value="Save Dependents" class="btn btn-primary" />
</li>
</ul>
</div>
</div>
</section>
}
@使用(Html.BeginForm(“Compare”,“Quote”,new{ReturnUrl=ViewBag.ReturnUrl},FormMethod.Post,new{@class=“form horizontal”,role=“form”}))
{
@Html.AntiForgeryToken()
#
名字
姓
出生日期
电子邮件
电话号码
1.
@文本框(“敬礼”,新的{@Value=”“);
@TextBoxFor(m=>m.FirstName,新的{@Value=Model.FirstName,@class=“form control”})
@Html.ValidationMessageFor(m=>m.FirstName)
@Html.TextBoxFor(m=>m.lasname,新的{@Value=Model.lasname,@class=“form control”})
@Html.ValidationMessageFor(m=>m.姓氏)
@TextBoxFor(m=>m.DOB,新的{@Value=Model.DOB,@class=“form control”})
@Html.ValidationMessageFor(m=>m.DOB)
@Html.TextBoxFor(m=>m.Email,新的{@Value=Model.Email,@class=“form control”})
@Html.ValidationMessageFor(m=>m.Email)
@DropDownListFor(m=>m.Extensions,Model.Extensions,“Ext”,new{@class=“formcontrolext0”})
@Html.ValidationMessageFor(m=>m.Extensions)