错哪了?在线!!!!

tiantian1980 2004-04-30 06:58:27
<% @ Page language="C#"%>
<script language="C#" runat="server">
public void ToRigtList(object sender,EventArgs e)
{
for(int i=0; i<lbox1.Items.Count;i++)
{
ListItem item=lbox1.Items[i];
if(item.Selected)
{
lbox2.Items.Add(item);
lbox1.Items.Remove(item);
}
}
}
public void ToLeftList(object sender,EventArgs e)
{
for(int i=0; i<lbox2.Items.Count;i++)
ListItem item=lbox2.Items[i];
if(item.Selected)
{
lbox1.Items.Add(item);
lbox2.Items.Remove(item);
}
}
</script>
<html>
<head>
<title><title>
</head>
<body>
<b>ListBox演示</b>
<hr>
<form runat="server">
<table>
<tr>
<td>
<b>ListBox容器1:</b><br>
<asp:ListBox id="lbox1" Rows=5 SelectionMode="Multiple" runat="server">
<asp:ListItem>天天</asp:ListItem>
<asp:ListItem>天健</asp:ListItem>
<asp:ListItem>皇帝</asp:ListItem>
<asp:ListItem>皇后</asp:ListItem>
<asp:ListItem>靖靖</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:Button id="ToRight" Text="-->" OnClick="ToRightList" runat="server"/>
<asp:Button id="ToLeft" Text="<--" OnClick="ToLeftList" runat="server"/>
</td>
<td>
<b>ListBox容器2:</b><br>
<asp:ListBox id="lbox2" Rows=5 SelectionMode="Multiple" runat="server"/>
</td>
</form>
</body>
</html>


...全文
21 14 点赞 打赏 收藏 举报
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wangsaokui 2004-05-01
12点前给分我还可以在排行榜上涨涨!!谢谢!
  • 打赏
  • 举报
回复
wangsaokui 2004-05-01
晚了,兄弟!

前台就是你的页面,文件名后缀为aspx
后台就是你的代码,文件名后缀为aspx.vb或aspx.cs
  • 打赏
  • 举报
回复
tiantian1980 2004-05-01
哪位仁兄,解释下前台后台,不懂!
我一直就一下就运行出来!
回复人: wangsaokui(无间道II(前传)) 分一定给!就今12点前吧!
  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
后台:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication2
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ListBox lbox1;
protected System.Web.UI.WebControls.Button ToRight;
protected System.Web.UI.WebControls.Button ToLeft;
protected System.Web.UI.WebControls.ListBox lbox2;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ToRight.Click += new System.EventHandler(this.ToRight_Click);
this.ToLeft.Click += new System.EventHandler(this.ToLeft_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void ToRight_Click(object sender, System.EventArgs e)
{
for(int i=0; i<lbox1.Items.Count;i++)
{
ListItem item=lbox1.Items[i];
if(item.Selected)
{
lbox2.Items.Add(item.Text);
lbox1.Items.Remove(item);
}
}
}

private void ToLeft_Click(object sender, System.EventArgs e)
{
for(int i=0; i<lbox2.Items.Count;i++)
{
ListItem item=lbox2.Items[i];
if(item.Selected)
{
lbox1.Items.Add(item.Text);
lbox2.Items.Remove(item);
}
}
}
}
}
  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
前台:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
</HEAD>
<body>
<b>ListBox演示</b>
<hr>
<form runat="server" ID="Form1">
<table>
<tr>
<td>
<b>ListBox容器1:</b><br>
<asp:ListBox id="lbox1" Rows="5" SelectionMode="Multiple" runat="server">
<asp:ListItem>天天</asp:ListItem>
<asp:ListItem>天健</asp:ListItem>
<asp:ListItem>皇帝</asp:ListItem>
<asp:ListItem>皇后</asp:ListItem>
<asp:ListItem>靖靖</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:Button id="ToRight" Text="-->" runat="server" /><BR>
<asp:Button id="ToLeft" Text="<--" runat="server" />
</td>
<td>
<b>ListBox容器2:</b><br>
<asp:ListBox id="lbox2" Rows="5" SelectionMode="Multiple" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</HTML>
  • 打赏
  • 举报
回复
hnahzx 2004-04-30
看到有天天天健皇帝皇后靖靖,觉得有趣.能不能冒昧的问一下,你做的什么系统?
  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
你下面的/table没有,上面的/title写错了

private void ToRight_Click(object sender, System.EventArgs e)
{
for(int i=0; i<lbox1.Items.Count;i++)
{
ListItem item=lbox1.Items[i];
if(item.Selected)
{
lbox2.Items.Add(item.Text);
lbox1.Items.Remove(item);
}
}
}

private void ToLeft_Click(object sender, System.EventArgs e)
{
for(int i=0; i<lbox2.Items.Count;i++)
{
ListItem item=lbox2.Items[i];
if(item.Selected)
{
lbox1.Items.Add(item.Text);
lbox2.Items.Remove(item);
}
}
}
  • 打赏
  • 举报
回复
tiantian1980 2004-04-30
我改后的代码,运行是空白!怪!!!!!
<% @ Page language="C#"%>
<script language="C#" runat="server">
public void ToRightList(object sender,EventArgs e)
{
for (int i=0; i<lbox1.Items.Count; i++) {
if (lbox1.Items[i].Selected)
lbox2.Items.Add(lbox1.Items[i].Text);
lbox1.Items.Remove(lbox1.Items[i].Text);
}

}
public void ToLeftList(object sender,EventArgs e)
{
for (int i=0; i<lbox2.Items.Count; i++) {
if (lbox2.Items[i].Selected)
lbox1.Items.Add(lbox2.Items[i].Text);
lbox2.Items.Remove(lbox2.Items[i].Text);
}

}
</script>
<html>
<head>
<title><title>
</head>
<body>
<b>ListBox演示</b>
<hr>
<form runat="server">
<table>
<tr>
<td>
<b>ListBox容器1:</b><br>
<asp:ListBox id="lbox1" Rows=5 SelectionMode="Multiple" runat="server">
<asp:ListItem>天天</asp:ListItem>
<asp:ListItem>天健</asp:ListItem>
<asp:ListItem>皇帝</asp:ListItem>
<asp:ListItem>皇后</asp:ListItem>
<asp:ListItem>靖靖</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:Button id="ToRight" Text="-->" OnClick="ToRightList" runat="server"/></br>
<asp:Button id="ToLeft" Text="<--" OnClick="ToLeftList" runat="server"/>
</td>
<td>
<b>ListBox容器2:</b><br>
<asp:ListBox id="lbox2" Rows=5 SelectionMode="Multiple" runat="server"/>
</td>
</form>
</body>
</html>

  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
for(int i=0; i<lbox2.Items.Count;i++)
ListItem item=lbox2.Items[i];
if(item.Selected)
{
lbox1.Items.Add(item);
lbox2.Items.Remove(item);
}
==============>
for (int i=0; i<lbox2.Items.Count; i++) {
if (lbox2.Items[i].Selected)
lbox1.Items.Add(lbox2.Items[i].Text);
lbox2.Items.Remove(lbox2.Items[i].Text);
}

兄弟,你也太懒了点吧
  • 打赏
  • 举报
回复
tiantian1980 2004-04-30
高手哪去了????????????????????????
高手哪去了????????????????????????
  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
参考

void Check_Clicked(Object sender, EventArgs e) {
Message.Text="Selected Item(s):" + "<br>" + "<br>";
for (int i=0; i<checkboxlist1.Items.Count; i++) {
if (checkboxlist1.Items[i].Selected)
Message.Text=Message.Text + checkboxlist1.Items[i].Text + "<br>";
}
}
  • 打赏
  • 举报
回复
tiantian1980 2004-04-30
Line 18: ListItem item=lbox2.Items[i];
  • 打赏
  • 举报
回复
tiantian1980 2004-04-30
Compiler Error Message: CS1023: Embedded statement cannot be a declaration or labeled statement

Source Error:Line 18
  • 打赏
  • 举报
回复
wangsaokui 2004-04-30
给个出错提示嘛
  • 打赏
  • 举报
回复
相关推荐
发帖
.NET社区
加入

5.9w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2004-04-30 06:58
社区公告
暂无公告