mvc java html页面_MVC4 cshtml页面函数调用
我需要在mvc页面首次加载时在可编辑文本框中显示一个值(如果存在) . 我有一个功能,将负责获取我需要的值,但我需要从当前模型传递参数,以从数据库中获得我需要的 . 我遇到的问题是将此值放入文本框中 . 我试过的是
CSHTML:
@Html.TextBoxFor(model => model.AdjustedLiabilityAmount, new { @Value=OBS_LIB.BLL.JeopardyAssessment.JeopardyAssessment.GetLatestAdjustedLiabilityAmount(Model.DOTNumber, Model.LiabilityAmount))}
我得到一个红色波浪形的“当前上下文中不存在名称' Value '”
所以我尝试了一种我读过的不同技术,就像这样 .
控制器:
public ActionResult Index()
{
ViewBag.AdjustedValue = OBS_LIB.BLL.JeopardyAssessment.JeopardyAssessment.GetLatestAdjustedLiabilityAmount(Model.DOTNumber, Model.LiabilityAmount);
CSHTML:
@Html.TextBoxFor(model => model.AdjustedLiabilityAmount, new { @Value=ViewBag.AdjustedValue)}
这次我得到了红色波浪形的“名字'模型'在当前背景下不存在 . ”
我确定我只是缺少一些基本的东西,因为我是MVC的新手 .
任何帮助深表感谢 .
整个ActionResult指数:
public ActionResult Index()
{
ViewBag.AdjustedValue = OBS_LIB.BLL.JeopardyAssessment.JeopardyAssessment.GetLatestAdjustedLiabilityAmount(Model.DOTNumber, Model.LiabilityAmount);
var Report = new OBS_LIB.DTO.JeopardyAssessmentReport();
Report.Stage = 1;
Report.Status = "Active";
Report.ReportItems = OBS_LIB.BLL.JeopardyAssessment.JeopardyAssessment.GetJAReportItems(Report.Stage, Report.Status);
return View(Report);
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
