You can start by adding a description to the div and give your drop-down list a unique identifier:
@model FND.Models.ViewLender
@{
ViewBag.Title = "Change Lender";
}
@using (Html.BeginForm())
{
@Html.Label("Change Lender : ")
@Html.DropDownList("Ddl_Lender", Model.ShowLenderTypes, new { id = "lenderType" })
<div id="description">
@Html.DisplayFor(model => model.Description)
</div>
}
Now all that remains is to subscribe to the onchangejavascript event of this drop-down list and update the corresponding description.
For example, if you use jQuery, this is a pretty trivial task:
$(function() {
$('#lenderType').change(function() {
var selectedDescription = $(this).find('option:selected').text();
$('#description').html(selectedDescription);
});
});
, , , , . AJAX , . , , URL- data-* HTML5 , javascript:
@Html.DropDownList(
"Ddl_Lender",
Model.ShowLenderTypes,
new {
id = "lenderType",
data_url = Url.Action("GetDescription", "SomeController")
}
)
.change AJAX:
$(function() {
$('#lenderType').change(function() {
var selectedValue = $(this).val();
$.ajax({
url: $(this).data('url'),
type: 'GET',
cache: false,
data: { value: selectedValue },
success: function(result) {
$('#description').html(result.description);
}
});
});
});
, , , , :
public ActionResult GetDescription(string value)
{
string description = GoGetTheDescription(value);
return Json(new { description = description }, JsonRequestBehavior.AllowGet);
}