我有一个文本区域,需要在某些条件下更改输入类型。我想将此信息作为 ViewBag 参数发送,但我不知道该怎么做。我虽然在控制器中这样做:
if(inputtext == 1)
ViewBag.TextBox = @Html.TextBoxFor(m => m.Name, new { @class =\"inputtext\"})
if(inputtext == 2)
ViewBag.TextBox = @Html.TextAreaFor(m => m.Name, new { @class =\"inputtext2\"})
我的观点是这样的:
@Html.Raw(ViewBag.TextBox)
但不要工作。关于如何做到这一点的任何想法?