| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 871 人关注过本帖
标题:非静态字段、方法或属性“system_userInfo.TextBox1”要求对象引用”
只看楼主 加入收藏
kangaroonj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-10-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
非静态字段、方法或属性“system_userInfo.TextBox1”要求对象引用”
    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetCityList(string prefixText, int count, string contextKey)
    {
        string strState = TextBox1.Text;//????
        此处需要从页面上的一个TextBox1取值,不知道怎么写?报错“非静态字段、方法或属性“system_userInfo.TextBox1”要求对象引用”。

        //获取自动完成的选项数据
        
        List<string> list = new List<string>();

        string sql = string.Format("select top {0} name from t_b_xzqh where right(codeno,2)='00' and (name like '%{1}%' or dbo.f_GetPy(name) like '%{1}%')order by codeno", count, prefixText);
        var dr = SQLBase.ExecuteReader(sql);

        while (dr.Read())
        {
            list.Add(dr[0].ToString());
        }
        return list.ToArray();
    }
搜索更多相关主题的帖子: public count 
2013-10-08 03:48
shangsharon
Rank: 9Rank: 9Rank: 9
来 自:湖北武汉
等 级:蜘蛛侠
威 望:7
帖 子:221
专家分:1261
注 册:2012-3-25
收藏
得分:7 
方法是public static的,访问不到TextBox1.Text
如果去掉static应该是可以,但是不知道会不会影响你其他的地方.
2013-10-08 19:04
Jina_C
Rank: 2
等 级:论坛游民
帖 子:7
专家分:62
注 册:2013-9-18
收藏
得分:7 
传个参数?
 public static string[] GetCityList(string prefixText, int count, string contextKey, TextBox txtbox)
    {
        string strState = TextBox1.Text;//????
        此处需要从页面上的一个TextBox1取值,不知道怎么写?报错“非静态字段、方法或属性“system_userInfo.TextBox1”要求对象引用”。
        操作txtbox这个textbox就可以了
        //获取自动完成的选项数据
        ……
    }
调用的时候GetCityList(perfixText,count,contextKey,txtbox);
2013-10-09 14:24
303770957
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:6
帖 子:838
专家分:2125
注 册:2005-9-10
收藏
得分:7 
public static string[] GetCityList(string prefixText, int count, string contextKey,string strState);
将strState当做一个参数来传递,这个参数的值就是TextBox1.Text的值。

♂ 死后定当长眠,生前何须久睡。♀
2013-10-09 17:30
快速回复:非静态字段、方法或属性“system_userInfo.TextBox1”要求对象引用”
数据加载中...
 
   



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

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