<asp:TreeView> 向可通过JavaScript/JQuery访问的treenode添加附加信息?



是否有一种方法可以通过我可以通过JavaScript/jQuery访问ASP:TreeView的信息?

我的问题:我必须通过jQuery/javaScript(在客户端)中预防ASP:TreeView中的复选框,在不同的子类别中可以选择(或由刻板印象 - 预称分组)。当我要求使用$(this).next()。text();的treenode-text时,它已经起作用,因为它们在类别中有一个前缀(刻板印象),但是现在我必须隐藏该信息并且不能使用它去检查。

    $("[id*=TreeView1] input[type=checkbox]").bind("click", function () {
        var isChecked = $(this).is(":checked");
        if (isChecked) {
            zuletztSelektiert = zuletztSelektiert + $(this).next().text();
        }
        else {
            zuletztSelektiert = zuletztSelektiert.replace($(this).next().text(), '');
        }
        if (zuletztSelektiert != '') {
            // Welcher Stereotyp ist selektiert?
            var stereotype = zuletztSelektiert.substring(zuletztSelektiert.indexOf('«') + 1, zuletztSelektiert.indexOf('»'));
            $("[id*=TreeView1] input[type=checkbox]").each(function () {
                var currentStereotype = $(this).next().text().substring($(this).next().text().indexOf('«') + 1, $(this).next().text().indexOf('»'));
                if (currentStereotype != stereotype) {
                    var isChecked2 = $(this).is(":checked");
                    if (isChecked2) {
                        $(this).removeAttr("checked");
                        zuletztSelektiert = zuletztSelektiert.replace($(this).next().text(), '');
                        alert('It is not possible to select elements of different stereotypes. nn Selected Items:n' + zuletztSelektiert);
                    }
                }
            });
        }
    });

好吧,因为没有人知道答案我只是通过将刻板印象添加为get -param到链接目标url并导航到treenode

中的-tag来做到这一点。
   $("[id*=TreeView1] input[type=checkbox]").bind("click", function () {
        var selectedStereoType = $.trim($(this).next().prop("href").substring($(this).next().prop("href").indexOf("=") + 1));
        //return;
        var isChecked = $(this).is(":checked");
        if (isChecked) {
            //zuletztSelektiert = zuletztSelektiert + $(this).next().text();
            zuletztSelektiert = zuletztSelektiert + selectedStereoType;
        }
        else {
            //zuletztSelektiert = zuletztSelektiert.replace($(this).next().text(), '');
            zuletztSelektiert = zuletztSelektiert.replace(selectedStereoType, '');
        }
        if (zuletztSelektiert != '') {
            // Welcher Stereotyp ist selektiert?
            //var stereotype = zuletztSelektiert.substring(zuletztSelektiert.indexOf('«') + 1, zuletztSelektiert.indexOf('»'));
            var stereotype = selectedStereoType;
            var letzteMeldung = '';
            $("[id*=TreeView1] input[type=checkbox]").each(function () {
                //var currentStereotype = $(this).next().text().substring($(this).next().text().indexOf('«') + 1, $(this).next().text().indexOf('»'));
                var currentStereotype = $.trim( $(this).next().prop("href").substring($(this).next().prop("href").indexOf("=") + 1) );
                if (currentStereotype != stereotype) {
                    var isChecked2 = $(this).is(":checked");
                    if (isChecked2) {
                        $(this).removeAttr("checked");
                        zuletztSelektiert = zuletztSelektiert.replace($.trim( $(this).next().prop("href").substring($(this).next().prop("href").indexOf("=") + 1) ), '');
                        letzteMeldung='It is not possible to select elements of different stereotypes. nn Selected Items: ' + zuletztSelektiert;
                    }
                }
            });
            if (letzteMeldung != '') alert(letzteMeldung);
        }
    });

这就是我在c#.net中做到的treenode.navigateurl =" url?sterepype =" sterepype;

最新更新