1

我现在在这个上拔头发太久了。希望各位大侠能帮帮忙。

我有一个表单,允许用户从“技能”列表中添加“我的个人技能”。

在此处输入图像描述

我已经使用 jQuery 完成了“加号按钮 (+)”和减号按钮 (-) 代码,如下所示:

<script language="javascript" type="text/javascript">
function AddItSkills() {
    var selectedOptions = jQuery('#<%=ListITProgramming.ClientID %> option:selected');
    if (selectedOptions.length == 0) {
        alert("Please select option to move.");
        return false;
    }

    if (selectedOptions.length == 1) {
        if (jQuery("#<%=ListMyITProgramming.ClientID %> option[value='" + selectedOptions.val() + "']").length > 0) {
        }
        else {
            jQuery('#<%=ListMyITProgramming.ClientID %>').append(jQuery(selectedOptions).clone());
        }
    }
    else if (selectedOptions.length > 1) { jQuery(selectedOptions).each(function () { if (jQuery("#<%=ListMyITProgramming.ClientID %> option[value='" + this.value + "']").length > 0) { } else { jQuery('#<%=ListMyITProgramming.ClientID %>').append(jQuery(this).clone()); } }); }
    jQuery(selectedOptions).remove();
    return false;
}
function RemoveITSkills() {
    var selectedOptions = jQuery('#<%=ListMyITProgramming.ClientID %> option:selected');
    if (selectedOptions.length == 0) {
        alert("Please select option to move.");
        return false;
    }

    if (selectedOptions.length == 1) {
        if (jQuery("#<%=ListITProgramming.ClientID %> option[value='" + selectedOptions.val() + "']").length > 0) {
        }
        else {
            jQuery('#<%=ListITProgramming.ClientID %>').append(jQuery(selectedOptions).clone());
        }
    }
    else if (selectedOptions.length > 1) { jQuery(selectedOptions).each(function () { if (jQuery("#<%=ListITProgramming.ClientID %> option[value='" + this.value + "']").length > 0) { } else { jQuery('#<%=ListITProgramming.ClientID %>').append(jQuery(this).clone()); } }); }
    jQuery(selectedOptions).remove();
    return false;
}

在这种情况下,“技能”与数据库绑定,“我的个人技能”为空。用户将“技能”添加到“我的个人技能”中,然后单击“保存”按钮。

在后面的 c# 代码中,我无法从“我的个人技能”中获取项目列表,因为它们是通过 jQuery 添加的。

谁能给我指导以在后面的 c# 代码中获取“我的个人技能”项目?

4

1 回答 1

1

隐藏的领域将是这里的灵丹妙药。

第1步。向您的页面添加一个 asp hiddenfield 让我们说 hf1 是它的 id。

第2步。将 clientclick 事件添加到您的保存按钮

step3.在客户端clickevent中获取所有个人技能并使用逗号或'|'将它们变成单个字符串

第4步。将 hf1 值设置为 step3 生成的字符串,然后发布。

第 5 步。在服务器端获取 hf1 的值,这将与第 3 步中生成的字符串相同。

步骤 6。反序列化它并//做任何你想做的事情。

希望这有帮助

于 2013-06-25T12:07:14.463 回答