0

我是 Asp.Net 和 Razor 标记的新手,我需要一些帮助,

我有两个 Html.TextBoxFor 使用相同的属性来存储值,我在我的第一个 TextBoxFor 上插入文本,所以我期望相同的值会出现在第二个 Html.TextBoxFor 上。

我虽然可以使用相同的属性,但我不需要 Javascript 来影响第二个 TextBoxFor 的文本。

//Here is my first TextBoxFor

@Html.TextBoxFor(p => p.DeliveryNote.Shipment.SenderData.PtzipCode4, new { @class = "form-control", @style = "width:100%" })



//Here is my second TextBoxFor, as you can see they are using the same property PtzipCode4

@Html.TextBoxFor(p => p.DeliveryNote.Shipment.SenderData.PtzipCode4, new { @class = "form-control",  @style = "width:100%" })

//I even tried using the Value tag as you can see below, but the value kept it zero value

Html.TextBoxFor(p => p.DeliveryNote.Shipment.SenderData.PtzipCode4, new { @class = "form-control", @Value = Model.DeliveryNote.Shipment.SenderData.PtzipCode4,  @style = "width:100%" })

当我在 TextBox 上书写时,模型属性没有改变?我需要将信息发布回控制器吗?我虽然这个控制器(TextBoxFor)在服务器端工作。

非常感谢您的帮助,我想简要解释一下为什么这不起作用以及如何实现它。

4

0 回答 0