Hightlighted Checkbox inside webgrid not selectable in IE7

My application is in MVC 3 and I use the razor mechanism, I try to select the first element (the checkbox is checked by default) inside the web mesh, it is not selectable in IE7, here is the code

     $("#@item").change(function () {

    });
+5
source share
1 answer

Alright ... Let's do it step by step ... because you haven't suggested a lot of data ... I'm going to make a script for you:

will say that you have this checkbox checked:

@Html.CheckBoxFor(model=>model.isValid,new {id="chkValid"})

Of course, ISValid is a bool variable.

One easy way:

@Html.CheckBoxFor(model=>model.isValid,new {@checked = "checked"})

Now, if for some reason this doesn’t work ... you can always go the old-fashioned way ... JQuery: ready in the document .. to do this:

 $(document).ready(function () {
        $('chkValid').attr('checked')= true;
    });

Hope this helps


LAST EDIT: Good ... Try the following:
@Html.CheckBoxFor(model=>model.isValid,new {id="chkValid" , onclick="updateChk("+@model.parameter+")"}) // the value you need to send to the controller 

and this is the jquery function:

  function updateChk(parameter)
    {
            if (($('#chkValid').is(':checked')) {
                var check = true;
            } else {
                check = false;
            }
    //see if checkbox is checked and pass it to the controller in an Ajax call
            $.ajax({
                type: "POST",
                url: '@Url.Action("Action", "Controller")',

                data: "{parameter:parameter, status:'" + check + "'}",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                }
            });
        }

- , !

0

All Articles