javascript - MVC2 Html.HiddenFor - How to Set Value from ViewData -


having trouble here , not quite sure how it. i've attempted jquery no luck. have object , on create view, have parentid want set (it's in url well). so, i'm trying use html.hiddenfor populate new object when returned on post. but, doesn't work. i've tried following never returns value on post.

html:

<%: html.hidden("hiddenparentid", viewdata("parentid"))%> <%: html.hiddenfor(function(model) model.parentgroupid)%> 

javascript:

<script type="text/javascript">     $(document).ready(function () {         alert($('#hiddenparentid').val());         $('#parentid').val($('#hiddenparentid').val());     }); </script> 

as can see, on doc ready, set hidden parent id input value viewdata because hiddenfor doesn't have value attribute. hiddenparentid field in fact have value i'm setting because i'm alerting , it's got guid should have. now, first, i'm using vb in vb appreciated , second, if there's method solve issue, please advise. i'm trying accomplish id passed in url (which in controller i'm grabbing id , putting in viewdata) , set parentid property of object post save when object returned me.

please check id in html source hidden field, guess rendering different name.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -