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);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值