| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 473 人关注过本帖
标题:asp.net C#。。。的错误
只看楼主 加入收藏
ping燕s
Rank: 2
来 自:江西
等 级:论坛游民
帖 子:40
专家分:33
注 册:2009-9-22
结帖率:71.43%
收藏
已结贴  问题点数:30 回复次数:3 
asp.net C#。。。的错误
   刚学c#,谁帮调试下,纠正下。。
先谢啦。。


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;

public partial class ListPicker : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void SourceList_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
 
    }
    protected void AddAll_Click(object sender, EventArgs e)
    {
        TargetList.SelectedIndex = -1;
        foreach(ListItem li in SourceList.Items)
        {        AddItem(li);    }

    }

    protected void AddOne_Click(object sender, EventArgs e)
    {
        if (SourceList.SelectedIndex >= 0)
            AddItem(SourceList.SelectedItem);
    }

    protected void Remove_Click(object sender, EventArgs e)
    {
        if (TargetList.SelectedIndex >= 0)
        {
            TargetList.Items.RemoveAt(TargetList.SelectedIndex);
            TargetList.SelectedIndex = -1;
        }
    }

               protected void AddItem(ListItem li)
{
    TargetList.SelectedIndex = -1;
    TargetList.Items.Add(li);
}
    public ListItemCollection SelectedItems
    {
        get { return TargetList.Items; }
    }
    public Boolean AllowDuplicates
    {
        get
        {
            return (Boolean)ViewState["allowDuplicates"];
        }
        set
        {
            ViewState["allowDuplicates"] = value;
        }
    }

   

    }
       public  void AddSourceItem(String sourceItem)
{
    SourceList.Items.Add(sourceItem);
}
    public void ClearAll()
    {
        SourceList.Items.Clear();
        TargetList.Items.Clear();
    }
 protected   void AddItem(ListItem li)
    {
        TargetList.SelectedIndex = -1;
        if (this.AllowDuplicates == true)
        
            TargetList.Items.Add(li);
        else
        {
            if (TargetList.Items.FindByText(li.Text) == null)
        {
                TargetList.Items.Add(li);
            }
        }
}

错误    1    应输入 class、delegate、enum、interface 或 struct
错误    2    应输入 class、delegate、enum、interface 或 struct
错误    3    应输入 class、delegate、enum、interface 或 struct
 
上面那错误什么情况发生呢?????


   
搜索更多相关主题的帖子: asp 
2010-04-19 16:54
yms123
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:10 
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;
public partial class ListPicker : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void SourceList_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void AddAll_Click(object sender, EventArgs e)
    {
        TargetList.SelectedIndex = -1;
        foreach(ListItem li in SourceList.Items)
        {      
              AddItem(li);   
        }
    }
    protected void AddOne_Click(object sender, EventArgs e)
    {
        if (SourceList.SelectedIndex >= 0)
            AddItem(SourceList.SelectedItem);
    }
    protected void Remove_Click(object sender, EventArgs e)
    {
        if (TargetList.SelectedIndex >= 0)
        {
            TargetList.Items.RemoveAt(TargetList.SelectedIndex);
            TargetList.SelectedIndex = -1;
        }
    }
    protected void AddItem(ListItem li)
    {
       TargetList.SelectedIndex = -1;
       TargetList.Items.Add(li);
    }
    public ListItemCollection SelectedItems
    {
        get
        {
           return TargetList.Items;
        }
    }
    public Boolean AllowDuplicates
    {
        get
        {
            return (Boolean)ViewState["allowDuplicates"];
        }
        set
        {
            ViewState["allowDuplicates"] = value;
        }
    }

}

//下面这些函数属于哪个类?
public void AddSourceItem(String sourceItem)
{
   SourceList.Items.Add(sourceItem);
}
public void ClearAll()
{
    SourceList.Items.Clear();
    TargetList.Items.Clear();
}
protected void AddItem(ListItem li)
{
    TargetList.SelectedIndex = -1;
     if(this.AllowDuplicates == true)
        TargetList.Items.Add(li);
     else
     {
        if (TargetList.Items.FindByText(li.Text) == null)
        {
            TargetList.Items.Add(li);
        }
     }
}
2010-04-19 17:06
saitor
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:5
帖 子:373
专家分:1520
注 册:2009-5-18
收藏
得分:10 
方法写到类外了
2010-04-19 22:54
czyzhuo
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:17
帖 子:230
专家分:1459
注 册:2010-3-11
收藏
得分:10 
一个方法一定要确定属于哪个类,这就是面向对象的机制
2010-04-20 12:47
快速回复:asp.net C#。。。的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037755 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved