You are effectively wanting to do view/model binding on the client side. Usually one could leverage a framework like KnockOut.JS and KnockOut.Mappings to assist with creating the client models and binding to those.
However, if you can't go with that or don't want to mess with it, you can manually do things with JQuery and JS. This may be over kill, but I tend to lean towards more structure and clarity. One solution could be to iterate over your server side model and generate its client side counterpart. Then, set up a change event via Jquery and locate the corresponding client model in a collection based on a selected value. Once found, update the text area with the model's value. Code follows...
View Code (with client script):
@model SoPOC.Models.IdentifiFIConfigurationViewModel
@Html.DropDownListFor(model => model.SelectedConfigId,
new SelectList(Model.Config.ConfigurationList, "Key", "Key", Model.SelectedConfigId),
"Select a Config"
)
<textarea id="configDescription" rows="10"></textarea>
@section Scripts {
<script type="text/javascript">
//array to hold your client side models
ConfigItemList = []
//definition method to query your array
ConfigItemList.GetItem = function (condition) {
for (i = 0, L = this.length; i < L; i++) {
with (this[i]) {
if (eval(condition)) { return this[i]; }
}
}
}
//Your client side item model
ConfigItem = function (key, value) {
var self = this;
self.Key = key;
self.Value = value;
}
//function to update views with model data
function UpdateView(configItem) {
console.log(configItem);
$("#configDescription").val(configItem.Value);
}
//Your C# code to loop over your dictionary and create the client side version
@if(Model.Config.ConfigurationList.Any())
{
foreach(var item in Model.Config.ConfigurationList)
{
//We are mixing C# and JS code here
@:ConfigItemList.push(new ConfigItem(@item.Key, '@item.Value'));
}
}
$(function () {
//bind change event to drop down to update view with model data
$("#SelectedConfigId").change(function () {
UpdateView(ConfigItemList.GetItem("Key === "+ $(this).val()));
});
console.log(ConfigItemList.length);
console.log(ConfigItemList);
});
</script>
}
The important parts are the server side iterations over your Dictionary object generating client side models to store into a client side array. After that, you have all the data in a usable structure you can query for. I left the debug output in to help you troubleshoot if needed.