私は国名をリストするドロップダウンリストを持っています ユーザーがドロップダウンリストから任意の国を選択すると、国選択に基づいて、データ(AgencyName、AgencyAddr、Pincode)データベースから読み込まれ、右側のテキストボックスに入力されます。ドロップダウン内の選択した国が選択されたままになります。ドロップダウンリストの選択変更にMVC3ページのAJAXを使用したドロップダウンリストによるページの部分的なポストバックEF4
、私はしなさいここに私
を助けるポストバックするためにページ全体をしたくない私のEF4である - ModelClasses
public class Country
{
public int CountryID { get; set; }
public string CountryName { get; set; }
}
public class AgencyInfo
{
public int CountryID { get; set; }
public string AgencyName { get; set; }
public string AgencyAddr { get; set; }
public int Pincode { get; set; }
}
ここに私のMVC4かみそりページIndex.cshtmlがある
@using (Ajax.BeginForm(
"Index",
"Home",
new AjaxOptions { UpdateTargetId = "result" }
))
{
@Html.DropDownList("SelectedCountryId", Model.CountryList, "(Select one event)")
}
<div id=’result’>
<fieldset>
<legend>Country Details: </legend>
<div>
<table>
<tr>
<td>
<span>Country Name </span>
<br />
@Html.EditorFor(model => model.Countries.Name)
@Html.ValidationMessageFor(model => model. Countries.Name)
</td>
<td>
<span>Agency Name </span>
<br />
@Html.EditorFor(model => model.AgencyInfo.AgencyName)
@Html.ValidationMessageFor(model => model.AgencyInfo.AgencyName)
</td>
</tr>
<tr>
<td>
<span>Address Info </span>
<br />
@Html.EditorFor(model => model. AgencyInfo.Address)
@Html.ValidationMessageFor(model => model. AgencyInfo.Address)
</td>
<td>
<span>Pin Code </span>
<br />
@Html.EditorFor(model => model. AgencyInfo.PinCode)
@Html.ValidationMessageFor(model => model. AgencyInfo.PinCode)
</td>
</tr>
<tr>
<td>
<input type="submit" value="Modify" /><input type="submit" value="Delete" />
</td>
<td>
<input type="submit" value="Save" /><input type="submit" value="View Resources" />
</td>
</tr>
</table>
</div>
</fieldset>
</div > @end of result [email protected]
お勧めはありますか?ありがとうございます