0

我有一个带有 select2 插件的列表框:

标记:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" style="top: 400px; position: absolute; z-index: 0;">
    <ContentTemplate>

    </ContentTemplate>
    <Triggers>

    </Triggers>
</asp:UpdatePanel>

<asp:ListBox ID="Cliente" class="select2-select" runat="server" style="width: 100%">
    <asp:ListItem></asp:ListItem>
    <asp:ListItem>Value 1</asp:ListItem>
    <asp:ListItem>Vale 2</asp:ListItem>
</asp:ListBox>

Javascript:

    $('.select2-select').select2({
        maximumSelectionLength: 1,
        allowClear: true,
        placeholder: "Select..."
    });
    $(".select2-select").on("select2:select", function (e) {
        refreshPanel();
    });
    $(".select2-select").on("select2:unselect", function (e) {
        refreshPanel();
    });

    function refreshPanel() {
        __doPostBack("<%=UpdatePanel1.UniqueID%>", '');
    }

VB.NET

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    dim test as string = listbox.text

结束子

面板已正确更新并且一切正常,但是当我清除 Listbox __postback 时,会触发但 listbox.text 仍然包含最后一个值。

我该如何解决这个问题?

- - - - - 编辑 - - - - - -

我使用右侧的小十字清除列表框。

在此处输入图像描述

4

1 回答 1

0

这可能会奏效

test.value.clear

或者:

listBox1.Items.Clear
于 2016-02-02T10:36:03.823 回答