Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

View without layout in MVC

If you want to show view without any surrounding _Layout page, you can set Layout=null.

Code sample,

With following custom error view, you displayed without surrounding _Layout page.

    Layout = null;
<div class="alert alert-danger alert-dismissible fade show">
        <h5>Error! </h5>
        <h6>Something went wrong, contact admin, or try again</h6>

Exception handling for document ready in jQuery

Errors in their jQuery $(document).ready function breaks page or prevent executing important code, You can avoid this with simple try..catch approach

Code example

$(document).ready(function () {
try {
  //your all JavaScript/jQuery code
} catch (error) {
    // handle error
    //Default code when error/or exception this will execute

Check-Uncheck all child checkboxes if parent checkbox checked or unchecked

In a table, with rows, every row has a check box, and there is a main check box at the thead.

Use following code example if you want to check and uncheck child check box when parent check box checked or unchecked(on change)

Code example

$("#chkParent").change(function () {
            if ($(this).prop('checked')) {
                $('#c4uSampleTable tbody input:checkbox ').each(function () {
                    $(this).prop('checked', true);
            } else {
                $('#c4uSampleTable tbody input:checkbox').each(function () {
                    $(this).prop('checked', false);