asp.net mvc - JavaScript in MVC Editor template doesn't render properly -
i'm moving controls view editor. in editor have hiddenfor:
@html.hiddenfor(m => m.emaildatavariables)
i have javascript tries read (this works in original page, not in view):
var myvalue = document.getelementbyid('emaildatavariables').value;
the hiddenfor
renders out (which breaks above javascript):
<input id="emailtemplate_emaildatavariables" name="emailtemplate.emaildatavariables" type="hidden" value="mydata">
should assume control named emailtemplate.emaildatavariables
, write javascript this:
var myvalue = document.getelementbyid('emailtemplate.emaildatavariables').value;
or there better way handle this?
you have 2 options.
1) assume id emailtemplate_emaildatavariables
, update js accordingly.
2) give unique id know.
@html.hiddenfor(m => m.emaildatavariables, new {id = "emaildatavariables"})