0
我正在尝试用添加到我的列表框中的值填充隐藏字段。我得到的消息_delimiter没有声明。所以隐藏字段值将是123456,651456,654321等。使用分隔符填充隐藏字段。 _delimiter未声明
<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
THanks我将其更改为public并且正在工作,但现在我收到错误Microsoft JScript运行时错误:属性'$'的值为null或未定义,而不是$ hidlistbox = $(' #<%= hidListBox.ClientID%>');线? – user1342164
@ user1342164与我有的信息我不知道可能是什么错误。没有正确加载jQuery可能(?),或者因为你的评估正在工作,也许它以某种方式破坏语法? – Matias
感谢您的帮助 – user1342164