C# asp.net mvc Set CheckBoxFor checked-property with Model-Value
<p>In my form i have a chekbox and when i click the checkbox a textbox is enabled.
When i submit the form i got both values(checkbox and textbox)and the site refresh,after the refresh the checkbox is checked but the textbox is disabled but has the last insert value.</p>

<p>If i submit again without making something the textbox returns null and not the last insert value.</p>

<p>I want that the checkbox got the value from my model and change the behavior of the textbox disabled-property und if no new value will be insert,it should return the last insert value. </p>

<p>When i set the model property of false the checkbox is also checked.
Has anyone a idea what i can do ?</p>

<p>View:</p>

<pre><code>@Html.TextBoxFor(m =&gt; m.FilterModel.FilterOrgNameValue, new { @class = "form-control", @id = "OrganisatioName", @disabled = "disabled" })
@Html.CheckBoxFor(m =&gt; m.FilterModel.FilterOrgNameIsCheckedValue, new { @class = "form-control", @id = "OrgNameChecked", @checked = (Model.FilterModel.FilterOrgNameIsCheckedValue ? "checked" : "unchecked")})
</code></pre>

<p>JavaScript:</p>

<pre><code> $("#OrgNameChecked").click(function () {

            $('#OrganisatioName').attr("disabled", $(this).is(':unchecked'));
        });
</code></pre>

<p>Model:</p>

<pre><code>public bool FilterOrgNameIsCheckedValue { get; set; }
</code></pre>

<p>Controller (Function which got called by submit):</p>

<pre><code>public ActionResult Index(AdminOrganizationModel m)
        {
            AdminOrganizationModel model = new AdminOrganizationModel();
            if(TempData["model"] != null)
            {
                m = (AdminOrganizationModel)TempData["model"];
            }
            if(m.FilterModel == null)
            {
                m.FilterModel = new AdminOrganizationFilterModel();
            }
            model = m;
            OrganizationBusinessObject organizationBusinessObject = new OrganizationBusinessObject(DbContext);
            var organizations = DbContext.GetAllEntitiesQueryable&lt;Organization&gt;();
            organizations = FilterOrganizations(organizations, model); 
            InitializeLicenseList(1);
            AdminOrganizationModelBuilder modelBuilder = new AdminOrganizationModelBuilder();
            IList&lt;AdminOrganizationModel&gt; organizationsModels = modelBuilder.GetModelCollection(organizations);
            model.Organizations = new AjaxGridFactory().CreateAjaxGrid(organizationsModels.AsQueryable(), 1, false, 10) as AjaxGrid&lt;AdminOrganizationModel&gt;;

            return View(model);
        }
</code></pre>

<p><a href="http://i.stack.imgur.com/40774.png" rel="nofollow">Fields after submit</a></p>