【发布时间】:2018-07-24 19:06:20
【问题描述】:
我有一个 DropDownList 和 3 个 TextBoxes 像这样:
@(Html.Kendo().DropDownList()
.Name("Lager")
.DataValueField("LagerId")
.DataTextField("LagerIdentifier")
.BindTo((System.Collections.IEnumerable)ViewData["Lager"])
)
@Html.TextBoxFor(model => model.Name1, new { @readonly = "readonly" })
@Html.TextBoxFor(model => model.Name2, new { @readonly = "readonly" })
@Html.TextBoxFor(model => model.Name3, new { @readonly = "readonly" })
基本上我想要实现的是,如果用户从 DropDown 中选择某些内容,我想相应地自动更改 TextBoxes 的值。
我的Lager 模型如下所示:
public class Lager
{
public int LagerId { get; set; }
public string LagerIdentifier { get; set; }
public string Name1 { get; set; }
public string Name2 { get; set; }
public string Name3 { get; set; }
}
【问题讨论】:
-
您希望页面在用户选择某些内容时回发,还是希望页面在没有回发的情况下更改?这将决定您是需要 AJAX(客户端)代码还是服务器端代码。
-
感谢您的回复!不,我不希望它发回。 ViewData["Lager"] 包含一个包含所有元素的列表。我只是不知道如何用 TextBoxes @AnnL 填充它。
-
这些值应该基于用户在 DropDownList 中选择的内容推导出来。它们是只读的,忘记提及了。 @乍得
标签: asp.net asp.net-mvc