我正在尝试使用添加到列表框中的值填充隐藏字段。我收到消息 _delimiter 未声明。所以隐藏字段值将是 123456,651456,654321 等。
<script language="javascript" type="text/javascript">
function getSelected(source, eventArgs) {
var s = $get("<%=NameTextBox.ClientID %>").value;
var opt = document.createElement("option");
opt.text = s.substring(s.length - 10);
opt.value = s.substring(s.length - 10);
document.getElementById('<%= Listbox.ClientID %>').options.add(opt);
$hidlistbox = $('#<%= hidListBox.ClientID %>');
$textbox = $('#<%= NameTextBox.ClientID %>');
$hidlistbox.val($hidlistbox.val() + $textbox.val() + '<%= _delimiter %>');
$textbox.val('');
}
Private Sub PopulateListBox()
Dim _delimiter As Char = ","c
If NameTextBox.Text = "" Then
Else
' Get value from text box
Dim textBoxValue As String = Me.NameTextBox.Text
' Create new item to add to list box
Dim newItem As New ListItem(textBoxValue)
' Add item to list box and set selected index
Listbox.Items.Add(newItem)
Listbox.SelectedIndex = Listbox.Items.Count - 1
hidListBox.Value = _delimiter.ToString
End If
End Sub