I know I’m doing something wrong somewhere, could somebody point it out to me?
I have a viewmodel, containing a CurrentSection property
public String CurrentSection {get; set;}
In the view, I call the viewmodel and jQuery
@model Application1.ViewModels.fooVM
@Scripts.Render("~/bundles/jquery")
Then I do the following (Which works in JSFiddle)
<script type="text/javascript">
$(document).ready(function () {
$("#CurrentSection").val('SecStoreIndex');
});
</script>
@Html.EditorFor(X => X.CurrentSection)
With the EditorFor rendering as
<input id="CurrentSection" name="CurrentSection" type="hidden" value="" />
Can anyone point out what I’m doing wrong?
I am holding my hands up and owning up to stupidity.
I was attempting to view the dynamically changed value view viewing the pages source. It suddenly occurred to me this does not show up. I threw in an alert and the value is being changed.
Sorry to waste your time.