'System.StackOverflowException'유형의 예외가 발생하는 이유가 발생했습니다. 내 htmlhelper에서?

베남

asp.net mvc의 확인란에 htmlhelper를 작성했지만 사용하고 싶을 때 예외가 표시됩니다. System.StackOverflowException' was thrown그것을 해결하는 방법. 그리고 실제로 htmlhelper에게 체크 박스 값을 제출하는 방법도 실제로 htmlhelper에게 값 체크 박스를 제출하고 싶습니다.

 public static class HelperUI
    {
        public static MvcHtmlString CheckBoxSimple(this HtmlHelper htmlHelper, bool IsCheck, string name, object htmlAttributes)
        {
            string checkBoxWithHidden = htmlHelper.CheckBoxSimple(IsCheck, name, htmlAttributes).ToHtmlString();
            string pureCheckBox = checkBoxWithHidden.Substring(0, checkBoxWithHidden.IndexOf("<input", 1));
            return new MvcHtmlString(pureCheckBox);
        }
    }




<div class="col-md-6">
    <div class="form-group row">
        status
        <div class="col-md-9">
            @Html.CheckBoxSimple(true, "Status", new { @class = "form-control", placeholder = "status" })

        </div>
    </div>
</div>
AlexB

StackOverflowException 은 종종 무한 루프 또는 무한 재귀로 인해 발생합니다.

귀하의 경우 CheckBoxSimple에는 자신을 무기한으로 호출합니다 . CheckBoxSimple대신 첫 번째 줄이 호출 됩니다 CheckBox.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관