在 webform 中,我们永远不必考虑控件 ID 或名称的唯一性。一切网络表单都会自动处理。所以告诉我,当我们为 html 控件的 ID 分配名称时,我该如何提供唯一的名称?请用小代码片段帮助我
只是看到它
@Html.DropDownListFor(x => x.Field, ModelClass.MakeSelectListUtenti(Model.Destinations), new { id="Destinations"})
在这里,我们将控件 ID 名称指定为“Destination”,但我如何指定“UniqueID_”+“Destination”之类的名称?
有人告诉我一种方法,如下所示
@Html.DropDownListFor(x => x.Field, ModelClass.MakeSelectListUtenti(Model.Destinations), new { id= @guid.NewGuid().ToString() + "Destinations"})
我想知道有没有其他方法。我听说在 mvc4 中引入了一些新技术。是真的吗……那是什么?
如果可能的话,还向我展示了在mvc 3/4中生成唯一客户端 ID 的各种方法。谢谢