极乐门资源网 Design By www.ioogu.com
前台
复制代码 代码如下:
<head runat="server">
<title>部门多选</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language="javascript" type="text/javascript">
function Ok()
{
window.close();
opener.document.all.txtOtherMan.value = window.Form2.hide.value;
}
function Cancel()
{
window.close();
}
</SCRIPT>
</head>
<body>
<form id="Form2" method="post" runat="server">
<TABLE style="WIDTH: 600px; POSITION: absolute; HEIGHT: 320px" cellSpacing="0" cellPadding="0" border="0">
<TR>
<TD style="WIDTH: 600px; HEIGHT: 20px">
<INPUT id="hide" type="hidden" value="<%=pass()%>">
<BUTTON id="ok" onclick="javascript:Ok();" type="button">确定</BUTTON>
<BUTTON id="cancel" onclick="javascript:Cancel();" type="button">取消</BUTTON>
<%-- <asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />--%>
</TD>
</TR>
<TR>
<TD style="WIDTH: 600px; height: 310px;" vAlign="top" align="left">
<DIV class="box" style="WIDTH: 600px ;HEIGHT: 300px; left: 0px; top: 0px;">
<asp:listbox id="UserList" style="Z-INDEX: 105; LEFT: 27px; POSITION: absolute; TOP: 56px" runat="server" Height="201px" Width="200px" SelectionMode="Multiple" DataTextField="Name" DataValueField="Name"></asp:listbox>
<asp:listbox id="lstSelEmp" style="Z-INDEX: 106; LEFT: 317px; POSITION: absolute; TOP: 58px" runat="server" Height="202px" Width="211px"></asp:listbox>
<asp:label id="Label4" style="Z-INDEX: 107; LEFT: 30px; POSITION: absolute; TOP: 32px" runat="server" CssClass="tttable">选取部门:</asp:label>
<asp:label id="Label5" style="Z-INDEX: 108; LEFT: 316px; POSITION: absolute; TOP: 34px" runat="server" CssClass="tttable" Height="18px" Width="108px">已选定部门:</asp:label>
<asp:button id="cmdAdd" style="Z-INDEX: 109; LEFT: 235px; POSITION: absolute; TOP: 145px" runat="server" CssClass="bsbttn" Height="27px" Width="63px" Text="添加->" onclick="cmdAdd_Click"></asp:button>
<asp:button id="cmdDel" style="Z-INDEX: 110; LEFT: 237px; POSITION: absolute; TOP: 184px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="<-删除" onclick="cmdDel_Click"></asp:button>
<asp:button id="cmdAddAll" style="Z-INDEX: 111; LEFT: 238px; POSITION: absolute; TOP: 64px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="全选" onclick="cmdAddAll_Click"></asp:button>
<asp:button id="cmdDelAll" style="Z-INDEX: 112; LEFT: 236px; POSITION: absolute; TOP: 104px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="全不选" onclick="cmdDelAll_Click"></asp:button>
</DIV>
</TD>
</TR>
</TABLE>
</form>
</body>
后台
复制代码 代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using Model;
public partial class Boarding_HarmSelRoleEmp : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if (BLL.EmailUser.GetEmailUserByID(Session["username"].ToString()).userCompany.ToString() == "北京")//登录判断
{
//左侧listbox绑定部门
this.UserList.Items.Clear();
this.UserList.Items.Add(new ListItem("总董事长办公室", "总董事长办公室"));
this.UserList.Items.Add(new ListItem("财务", "财务"));
this.UserList.Items.Add(new ListItem("市场", "市场"));
this.UserList.Items.Add(new ListItem("行政", "行政"));
this.UserList.Items.Add(new ListItem("IT", "IT"));
}
}
}
protected void cmdAdd_Click(object sender, System.EventArgs e)//添加到右侧
{
bool exist=false;//判断在右侧是否存在,不存在则将左侧部门添加到右侧
foreach( ListItem li in lstSelEmp.Items)
{
if(li.Value==UserList.SelectedItem.Value)
{
exist=true;
}
}
if(exist==false)
{
lstSelEmp.Items.Add(new ListItem(UserList.SelectedItem.Text,UserList.SelectedItem.Value));
}
}
protected void cmdDel_Click(object sender, System.EventArgs e)//取消右侧选择
{
lstSelEmp.Items.Remove(lstSelEmp.SelectedItem);
}
protected void cmdDelAll_Click(object sender, System.EventArgs e)//全部取消右侧选择
{
for(int i=0;i<lstSelEmp.Items.Count; )
lstSelEmp.Items.Remove(lstSelEmp.Items[i]);
}
protected void cmdAddAll_Click(object sender, System.EventArgs e)//全部添加到右侧
{
foreach(ListItem li in UserList.Items)
{
bool exist=false;
foreach( ListItem lised in lstSelEmp.Items)
if(lised.Value==li.Value)
exist=true;
if(exist==false)
lstSelEmp.Items.Add(new ListItem(li.Text,li.Value));
}
}
public string pass()
{
string txt="";
for(int j=0;j < lstSelEmp.Items.Count;j++)
{
txt+=lstSelEmp.Items[j];
txt+="','";
}
return txt;
}
}
复制代码 代码如下:
<head runat="server">
<title>部门多选</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language="javascript" type="text/javascript">
function Ok()
{
window.close();
opener.document.all.txtOtherMan.value = window.Form2.hide.value;
}
function Cancel()
{
window.close();
}
</SCRIPT>
</head>
<body>
<form id="Form2" method="post" runat="server">
<TABLE style="WIDTH: 600px; POSITION: absolute; HEIGHT: 320px" cellSpacing="0" cellPadding="0" border="0">
<TR>
<TD style="WIDTH: 600px; HEIGHT: 20px">
<INPUT id="hide" type="hidden" value="<%=pass()%>">
<BUTTON id="ok" onclick="javascript:Ok();" type="button">确定</BUTTON>
<BUTTON id="cancel" onclick="javascript:Cancel();" type="button">取消</BUTTON>
<%-- <asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />--%>
</TD>
</TR>
<TR>
<TD style="WIDTH: 600px; height: 310px;" vAlign="top" align="left">
<DIV class="box" style="WIDTH: 600px ;HEIGHT: 300px; left: 0px; top: 0px;">
<asp:listbox id="UserList" style="Z-INDEX: 105; LEFT: 27px; POSITION: absolute; TOP: 56px" runat="server" Height="201px" Width="200px" SelectionMode="Multiple" DataTextField="Name" DataValueField="Name"></asp:listbox>
<asp:listbox id="lstSelEmp" style="Z-INDEX: 106; LEFT: 317px; POSITION: absolute; TOP: 58px" runat="server" Height="202px" Width="211px"></asp:listbox>
<asp:label id="Label4" style="Z-INDEX: 107; LEFT: 30px; POSITION: absolute; TOP: 32px" runat="server" CssClass="tttable">选取部门:</asp:label>
<asp:label id="Label5" style="Z-INDEX: 108; LEFT: 316px; POSITION: absolute; TOP: 34px" runat="server" CssClass="tttable" Height="18px" Width="108px">已选定部门:</asp:label>
<asp:button id="cmdAdd" style="Z-INDEX: 109; LEFT: 235px; POSITION: absolute; TOP: 145px" runat="server" CssClass="bsbttn" Height="27px" Width="63px" Text="添加->" onclick="cmdAdd_Click"></asp:button>
<asp:button id="cmdDel" style="Z-INDEX: 110; LEFT: 237px; POSITION: absolute; TOP: 184px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="<-删除" onclick="cmdDel_Click"></asp:button>
<asp:button id="cmdAddAll" style="Z-INDEX: 111; LEFT: 238px; POSITION: absolute; TOP: 64px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="全选" onclick="cmdAddAll_Click"></asp:button>
<asp:button id="cmdDelAll" style="Z-INDEX: 112; LEFT: 236px; POSITION: absolute; TOP: 104px" runat="server" CssClass="bsbttn" Height="30px" Width="60px" Text="全不选" onclick="cmdDelAll_Click"></asp:button>
</DIV>
</TD>
</TR>
</TABLE>
</form>
</body>
后台
复制代码 代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using Model;
public partial class Boarding_HarmSelRoleEmp : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if (BLL.EmailUser.GetEmailUserByID(Session["username"].ToString()).userCompany.ToString() == "北京")//登录判断
{
//左侧listbox绑定部门
this.UserList.Items.Clear();
this.UserList.Items.Add(new ListItem("总董事长办公室", "总董事长办公室"));
this.UserList.Items.Add(new ListItem("财务", "财务"));
this.UserList.Items.Add(new ListItem("市场", "市场"));
this.UserList.Items.Add(new ListItem("行政", "行政"));
this.UserList.Items.Add(new ListItem("IT", "IT"));
}
}
}
protected void cmdAdd_Click(object sender, System.EventArgs e)//添加到右侧
{
bool exist=false;//判断在右侧是否存在,不存在则将左侧部门添加到右侧
foreach( ListItem li in lstSelEmp.Items)
{
if(li.Value==UserList.SelectedItem.Value)
{
exist=true;
}
}
if(exist==false)
{
lstSelEmp.Items.Add(new ListItem(UserList.SelectedItem.Text,UserList.SelectedItem.Value));
}
}
protected void cmdDel_Click(object sender, System.EventArgs e)//取消右侧选择
{
lstSelEmp.Items.Remove(lstSelEmp.SelectedItem);
}
protected void cmdDelAll_Click(object sender, System.EventArgs e)//全部取消右侧选择
{
for(int i=0;i<lstSelEmp.Items.Count; )
lstSelEmp.Items.Remove(lstSelEmp.Items[i]);
}
protected void cmdAddAll_Click(object sender, System.EventArgs e)//全部添加到右侧
{
foreach(ListItem li in UserList.Items)
{
bool exist=false;
foreach( ListItem lised in lstSelEmp.Items)
if(lised.Value==li.Value)
exist=true;
if(exist==false)
lstSelEmp.Items.Add(new ListItem(li.Text,li.Value));
}
}
public string pass()
{
string txt="";
for(int j=0;j < lstSelEmp.Items.Count;j++)
{
txt+=lstSelEmp.Items[j];
txt+="','";
}
return txt;
}
}
标签:
listbox,单选,全选
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无asp.net listbox实现单选全选取消的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2025年01月25日
2025年01月25日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]