ここでは2つのリストボックスがあります。追加ボタンをクリックすると、項目はasp.netの2番目のリストボックスにjqueryを使って追加する必要があります。このコードで何が間違っていますか?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListBoxExample.aspx.cs" Inherits="ListBoxExample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Adding,removing elements from First Listbox to Second Listbox</title>
<style type="text/css">
.lstbx1
{
font-family: Verdana;
font-size: medium;
font-style: normal;
background-color: Aqua;
height: auto;
width: auto;
}
.lstbx2
{
font-family: Verdana;
font-size: medium;
font-style: normal;
background-color: Lime;
height: auto;
width: auto;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js" />
<script type="text/javascript">
function Move_Elements() {
$("#lstbx1").appendTo("#lstbx2");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:ListBox ID="lstbx1" runat="server" CssClass="lstbx1" SelectionMode="Multiple">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
<asp:ListItem>Four</asp:ListItem>
<asp:ListItem>Five</asp:ListItem>
<asp:ListItem>Six</asp:ListItem>
<asp:ListItem>Seven</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:ListBox ID="lstbx2" runat="server" CssClass="lstbx2"></asp:ListBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnadd" runat="server" Text="Add" OnClientClick="Move_Elements();" />
</td>
<td>
<asp:Button ID="btnremove" runat="server" Text="Remove" OnClientClick="" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
...これを試してみてください – Vivek
Move_Elements()で何をしようとしていますか?そうではありません。 – Pradeep