Tôi đã có một ASP.NET MVC Xem thực sự đơn giản mà có một đơn giản string
làm mô hình.EditorFor (..) ném một ngoại lệ khi mô hình của tôi là null trong ứng dụng ASP.NET MVC của tôi
ví dụ:
@model string
Khi tôi làm như sau, quan điểm ném một ngoại lệ, nếu giá trị mô hình là null
(mà xảy ra khi người sử dụng đất đầu tiên về vấn đề này xem/trang/tài nguyên).
Value cannot be null or empty.
Parameter name: name
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Value cannot be null or empty.
Parameter name: name
<td>@Html.EditorFor(model => model)</td>
Làm thế nào tôi có thể tạo ra một input box
sử dụng EditorFor(..)
khi giá trị chuỗi mô hình là null?
Bạn không thể. Tên trường sẽ nhận được trong biểu mẫu là gì? – bzlm