我在Asp.net MVC將數據綁定的跨度與ASP MVC的數據庫,使用模型綁定
我需要怎麼做,然後反給了它的價值模型綁定一些建議很新。
我有兩個modal
Pages.in第一個我有這個計數器供用戶選擇他們的要求的數量是這樣的:在 當用戶點擊加號圖標數改爲By Javascript
當用戶點擊下一個按鈕,下一個模態頁面顯示,其中我有selecteddate
和number of travelers
那裏的JavaScript。也是我想要模型綁定器作爲它的一個對象的形式。
這裏是我的下一個模式頁的概要
<p>
<span id="selecteddate"></span>
<span id="selectedcount"></span>
<span id="selectedprice"></span>
</p>
的觀點,這裏是JavaScript的:
$(".nextbtn").click(function() {
$("#selecteddate").html("Selected Date is : "+$("#showdate").html());
$("#selectedprice").html("Total Price is : " + $("#tpriceforall").html());
$("#selectedcount").html($("#shownum").html());
});
和它工作正常。
而且我也在這個下一個模態頁面中有一個窗體。我想將用戶的輸入數據傳遞給數據庫+ span
#selectedcount
中的可用數字java script set it each time
。
因爲我想使用ModelBinder
,有一個輸入它將被隱藏。 但只是爲了傳遞數據。這裏是我的模型請求TravelersCount輸入
<div class="form-group">
@Html.LabelFor(model => model.Request.TravelersCount, htmlAttributes: new {@class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Request.TravelersCount, new { htmlAttributes = new { @class = "form-control", @*@Value=?????*@ } })
@Html.ValidationMessageFor(model => model.Request.TravelersCount, "", new { @class = "text-danger" })
</div>
</div>
我應該寫什麼在EditorFor
Value
?
或者,如果這種方式是完全不規則的,請建議我一個新的。 真的很感謝你的幫助。謝謝
您的'EditorFor()'方法創建一個輸入'id =「Request_TravelersCount」'所以你只需要'$('#Request_TravelersCount').val($(「#selectedcount」)。text ));'設置它的值(並且從不嘗試在'HtmlHelper'方法中設置'value'屬性) –
@StephenMuecke哦,我的上帝它的作品:)真的很感謝你。你有可能回答這個問題嗎? –