有如下选项卡,每次选择的是第二个。但提交到后台,始终是第一个选项卡(Temperature)中的model
1.前台
<form id="main" method="post" data-ajax="true" data-ajax-success="afterSuccess" action="/Controls/Update">
<div class="row" style="color:#007A7c;font-size:20px;">
<div class="col-md-7" style="margin-top:90px">
<h4 class="text-left"> Settings</h4>
<!-- Nav tabs -->
<ul class="nav nav-tabs navbar-expand-sm bg-light" role="tablist">
<li class="nav-item">
<a class="nav-link " data-bs-toggle="tab" href="#Temperature"><h5>Temperature</h5></a>
</li>
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="tab" href="#Level"><h5>Level</h5></a>
</li>
</ul>
<div class="tab-content bg-light">
<div id="Temperature" class="container tab-pane" style="margin:2px; font-size:20px;">
<table class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D"> Name</td>
<td>
<input type="text" value="Stirrer" class="form-control input-group input-group-lg" data-ajax-success="afterSuccess" data-ajax="true" style="font-size:20px;" id="DisplayName" name="DisplayName" />
<input type="hidden" value="2" data-val="true" id="InDepth" name="InDepth" />
</td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Unit</td>
<td><input type="text" value="rpm" class="form-control input-group input-group-lg" style="font-size:20px;" id="Unit" name="Unit" /></td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Screen Priority(0,65)</td>
<td><input type="text" value="12" class="form-control input-group input-group-lg" style="font-size:20px;" data-val="true" data-val-required="The ScreenPriority field is required." id="ScreenPriority" name="ScreenPriority" /></td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Decimals</td>
<td><input type="button" value="2" class="form-control input-group input-group-lg" style="font-size:20px;" /></td>
</tr>
<tr>
<td><input type="submit" value="Confirm" class="form-control btn-primary" style="font-size:20px;" /></td>
<td><input type="reset" value="Cancel" class="form-control btn-secondary" style="font-size:20px;" /></td>
</tr>
</tbody>
</table>
</div>
<div id="Level" class="container tab-pane active" style="margin:2px; font-size:20px;">
<table class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Name</td>
<td>
<input type="text" value="pH" class="form-control input-group input-group-lg" data-ajax-success="afterSuccess" data-ajax="true" style="font-size:20px;" id="DisplayName" name="DisplayName" />
<input type="hidden" value="0" id="InDepth" name="InDepth" />
</td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Unit</td>
<td><input type="text" value="" class="form-control input-group input-group-lg" style="font-size:20px;" id="Unit" name="Unit" /></td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Screen Priority[0,65]</td>
<td><input type="text" value="10" class="form-control input-group input-group-lg" style="font-size:20px;" id="Unit" name="Unit" /></td>
</tr>
<tr>
<td style="font-size:20px;color:#008A7D">Decimals[0,4]</td>
<td><input type="button" value="2" class="form-control input-group input-group-lg" style="font-size:20px;" /></td>
</tr>
<tr>
<td><input type="submit" value="Confirm" class="form-control btn-primary" style="font-size:20px;" /></td>
<td><input type="reset" value="Cancel" class="form-control btn-secondary" style="font-size:20px;" /></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
2.后台
[HttpPost]
public IActionResult Update(Sensors sensor)
{
}