Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net listbox和javascript添加项目_Asp.net_Javascript_Listbox - Fatal编程技术网

Asp.net listbox和javascript添加项目

Asp.net listbox和javascript添加项目,asp.net,javascript,listbox,Asp.net,Javascript,Listbox,我有两个asp listbox控件和一个html输入按钮,我使用js将以前从DB加载的项从listbox A添加到B,效果很好,但是当我提交表单时,listbox B后面的代码中没有我添加的项可访问 我的想法是试图保存到服务器的往返,并使其在客户端,但似乎它不起作用 有什么想法吗 非常感谢您抽出时间 编辑 这是密码 <asp:ListBox ID="lstBoxOrgs" runat="server" Height="117px" Width="502px" SelectionMode=

我有两个asp listbox控件和一个html输入按钮,我使用js将以前从DB加载的项从listbox A添加到B,效果很好,但是当我提交表单时,listbox B后面的代码中没有我添加的项可访问

我的想法是试图保存到服务器的往返,并使其在客户端,但似乎它不起作用

有什么想法吗

非常感谢您抽出时间

编辑

这是密码

<asp:ListBox ID="lstBoxOrgs" runat="server" Height="117px"  Width="502px" SelectionMode="Multiple"></asp:ListBox>
<input type="button" value="Add" onclick="AddItems2Listbox('lstBoxOrgs', 'lstBoxUserRelOrgs') "/>
onclick=AddItems2Listbox'lstBoxOrgs','lstBoxUserRelOrgs'是一个javascript函数,用于将LisboxA中的项添加到listbox B中


谢谢你有两个选择。第一个选项是跟踪在隐藏变量中添加了哪些选项,并在服务器上读取这些选项

第二个选项是在页面提交时选择所有选项,并用于获取列表中选项的值


您不能像在后端一样引用您的选择,因为viewstate没有添加/删除选项的线索。

您有两个选项。第一个选项是跟踪在隐藏变量中添加了哪些选项,并在服务器上读取这些选项

第二个选项是在页面提交时选择所有选项,并用于获取列表中选项的值


您不能像在后端一样引用您的选择,因为viewstate没有添加/删除选项的线索。

请添加您的代码或简单案例,这样我们就更容易帮助您了。请添加代码或简单案例,这样我们就更容易帮助您了。
protected void AssignOrgs_Click(object sender, EventArgs e)
{
    foreach (ListItem orgItem in lstBoxUserRelOrgs.Items)
    {
        //Update database here...
    }

    //Commit updates to DB
    cdc.SubmitChanges();
}