c# - Textbox not showing output in MVC -
this question has answer here:
- how display text in mvc? 4 answers
i want show output in textbox in mvc. not displaying anything. used following code , attached screenshot below:
@html.textareafor(up => up.compileoutput) foreach (compilererror comperr in results.errors) { userprogram.compileoutput = "line number " + comperr.line + ", error number: " + comperr.errornumber + ", '" + comperr.errortext + ";" + environment.newline + environment.newline; } return view(userprogram);
the first image shows output binded particular textbox. in browser (image 2) shows nothing in textbox (red colour)
i wondering why did not got exception. return view(string)
view string parameter name, not show text.
i suggest use viewbag
instead. set error text in property name follow:
foreach (compilererror comperr in results.errors) { userprogram.compileoutput = "line number " + comperr.line + ", error number: " + comperr.errornumber + ", '" + comperr.errortext + ";" + environment.newline + environment.newline; } viewbag.errortext = userprogram.compileoutput;
you can later on retrieve value calling viewbag.errortext
razor view
Comments
Post a Comment