내 응용 프로그램이 MVC3 ASPX C#입니다. 내가 사용/비활성화 Html.EditorFor 수 있도록 노력하고 다음 컨트롤러에서ViewData를 사용하여 Html.EditorFor를 사용/사용하지 않음
public bool IsReadOnly { get; private set; }
: 뷰에서
if (MySession.Current._progress == 100)
ViewData["ReadOnly"] = true;
:
... Inherits="System.Web.Mvc.ViewPage<Models.CTAHFormEdit>" %>
<script runat="server" type="text/C#">
bool isReadOnly = false;
protected void Page_Load(object sender, EventArgs e)
{
if ((bool?)this.ViewData["ReadOnly"] == true)this.isReadOnly = true;
}
</script>
<%: Html.EditorFor(model => model.Vessel_calcification, Model.IsReadOnly)%>
이했던 모델에서 을 작동하지. 나는 또한 시도했다 :
<%: Html.EditorFor(model => model.Subject_motion, new { @disable = true })%>
did not also!
가장 좋은 해결책은 동일한보기에서 드롭 다운 목록과 체크 상자가 @disable = true 및 @readonly = true 또는 false를 사용하고 ViewBag을 사용하여 false를 변경할 수 있기 때문입니다. 모든 제안, 고마워요.
사용자 정의 EditorFor를 작성하려고 했습니까? http://stackoverflow.com/questions/5497183/how-to-create-custom-editor-display-templates-in-asp-net-mvc-3 나는 일반적으로 사용자 정의 EditorFor를 구축하는 대신 정적으로 내보기를 빌드하지만 그건 좋은 OO 조언이 아닙니다. –