私はこのコードを持っています:
public class AccountModel
{
[Required]
[Display(Name = "Subscription ID")]
public string SubscriptionId { get; set; }
[Required]
[Display(Name = "Storage Name")]
public string StorageName { get; set; }
[Required]
[Display(Name = "Storage Key")]
public string StorageKey { get; set; }
[Required]
[Display(Name = "Hosted Name")]
public string HostedName { get; set; }
....
}
と...
$('a.sign-in').live('click', function () {
alert("BINGO!");
var id = document.getElementById('id').value;
var name = document.getElementById('name').value;
var key = document.getElementById('key').value;
var select = document.getElementById("listahosted");
var selected = select.options[select.selectedIndex].text;
...
}
モデルに値を設定したいだけです->「選択した」値をモデルm.HostedNameに入れますどうすればよいですか?
よろしく
私の見解で更新
私の見解
@model WebManager.Models.AccountModel
@{
ViewBag.Title = "Account";
}
<h2>Account</h2>
<p>
Please enter your Azure account details.
</p>
@Html.ValidationSummary(true, "Invalid account. Please correct the errors and try again.")
@using (Html.BeginForm())
{
<div>
<fieldset>
<legend>Account Information</legend>
<div class="editor-label">
@Html.LabelFor(m => m.SubscriptionId)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.SubscriptionId, new { id = "id"})
@Html.ValidationMessageFor(m => m.SubscriptionId)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.StorageName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.StorageName, new { id = "name" })
@Html.ValidationMessageFor(m => m.StorageName)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.StorageKey)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.StorageKey, new { id = "key" })
@Html.ValidationMessageFor(m => m.StorageKey)
</div>
<p>
<a href="#login-box" class="login-window">
<input type="submit" value="Apply" /></a>
</p>
</fieldset>
</div>
<div id="login-box" class="login-popup">
<!--a href="#" class="close"><img src="close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a-->
<form method="post" class="signin" action="#">
<fieldset class="textbox">
<label class="hostedservice">
<span>Hosted Service</span>
<br />
<select id='listahosted' name='listahosted'>
<option>Choose your hosted</option>
</select>
</label>
<br />
<label class="deployments">
<span>Role</span>
<br />
<select id='listadeployments' name='listadeployments'>
<option>Choose your role</option>
</select>
</label>
<br />
<a class="sign-in">
<input type="submit" value="Sign In" /></a>
</fieldset>
</form>
</div>
私はここにjavascriptを入れていません。
状況: JS で埋められたコンボボックスがあり、選択した値をモデルに配置する必要があります。
すべてのヘルプは高く評価されています