在 asp.net MVC 中获取模型值但在传递给 View 时未显示任何内容。
Controller
public ActionResult Index(plan plan1)
{
var myCharge = new StripeChargeCreateOptions();
string apiKey = "";
var stripeClient = new StripeClient(apiKey);
var planService = new StripePlanService(apiKey);
StripePlan response = planService.Get("1234");
plan1.Amount = (response.Amount).ToString();
return View();
}
查看
<div>
@Html.TextBoxFor(m => m.Amount)
</div>
如何在文本框中显示金额值
最佳答案
希望您的 View 与 Model 类(实例是 plan1
)强绑定(bind)。所以,你需要在你的返回声明中指定你的模型
return View(plan1);
关于c# - 从 Controller 传递时数据不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44905872/