Question

Im using devexpress Html.DevExpress().ValidationSummary in my mvc project. My form contains a devexpress page control with 3 tabs. When there are client-side validation errors validation summary shows them, and every error is hyperlink. If you click it, the field with error is focused, but if the field is on other tab nothing happens. So the field is focused if it is on active tab. I'd like it to change the active tab and focus appropriate field. Is there a way to make it work right?

Was it helpful?

Solution

My colleague solved this problem using javascript and jQuery:

var nameControlTab = "myPageControl"; //name of your pagecontrol here

    $(document).ready(function () {
        $("tbody").on('click', 'a[href*="javascript:_aspxVSOnErrorClick("]', function () {

            var url = $(this).attr("href");
            url = url.substring(url.indexOf("'") + 1);
            url = url.substring(0, url.indexOf("'"));

            var idTab = $("#" + url + "_ET").parents('div[id*="' + nameControlTab + '_C"]').not(nameControlTab + '_CC')[0].id;

            var indexTab = idTab.substring((nameControlTab + '_C').length);

            SetTab(indexTab);

            return true;
        });
    });

function indexOf(array, value) {
        if ([].indexOf)
            return array.indexOf(value);
        else {
            for (var i = 0; i < array.length; i++)
                if (array[i] == value)
                    return i;
            return -1;
        }
    }

    function SetTab(indexTab) {
        this[nameControlTab].SetActiveTabIndex(indexTab);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top