vs提示string userName = Request.Form.Get("tetUserName").ToString();未将对象引用到对象实例
                                                                   排错提示:
                                                                   使用new关键字创建对象实例;
                                                                   在调用方法前通过检查确定方法是否为空;
这是什么问题啊?
如果我去掉ToString()的话能运行成功但没有传值?
怎么回事啊,谢谢~~

解决方案 »

  1.   

    string   userName   =   Request.Form.Get( "tetUserName ").Text.ToString();试试
      

  2.   

    应该是没有拿到值
    好好看看Get方法参数是不是正确
      

  3.   

    不行啊,错误提示:”string“并不包含”Text“的定义。。
      

  4.   

    tetUserName是个什么,是个控件的话不可能直接就ToString()的,要加.Text.ToString()
      

  5.   

    不包括 Request.Form.Get( "tetUserName ").Text的定义
      

  6.   

    tetUserName是HTML页中的Text控件的ID
      

  7.   

    if(!string.IsNullOrEmpty(Request.Form.Get( "tetUserName ")))
    {}
      

  8.   

    判断 Request.Form.Get( "tetUserName ")是否为null 
      

  9.   

    if(!string.IsNullOrEmpty(Request.Form.Get( "tetUserName "))) 
    {
        string userName = Request.Form.Get("tetUserName").ToString();
    }
    是这样用吗?
    不好意思,我刚学没多久
      

  10.   

    vs提示string   userName   =   Request.Form.Get( "tetUserName ").ToString();未将对象引用到对象实例 
        
    这是什么问题啊? 如果我去掉ToString()的话能运行成功但没有传值? 
    怎么回事啊,========
    0. string   userName   =   Request.Form.Get( "tetUserName ").ToString();
       string   userName   =   Request.Form.Get( "tetUserName").ToString();多出的空格!此外,1. 哪个老师教你 string anotherString; string s = anotherString.ToString()  的用法? 既然已经是 string 类型了,就不用浪费 CPU 去调用 ToString 方法了2. 结果你看,这里 anotherString 实际上 null,所以调用 anotherStirng.ToString() 就报 NulLRefEx 了3. 回到你的代码,注意 Request.Form.Get(string) 方法,实际上已经返回 stirng 类型结果了,所以不要多此一举4. 如果提交的页面没有包含指定的 name 那么 Form.Get 就返回 null,QueryString 也是同理5. 所以,健壮的程序需要:
     
    string v = Request.Form.Get(name);
    if(v != null) {
    // ...
    } else {
    // ..
    }
    看着北大青鸟的教程做的,,,郁闷运行综总是失败
    ======
    所以,估计也是个三岁小孩写的代码
      

  11.   

    codestring  userName=  Request.Form["tetUserName"];这样取看看。 
      

  12.   

    这个是明白了,那么怎么才能把值传过去呢
    string userName = Request.Form.Get("tetUserName");
            if (userName != null)
            {
                Response.Write("你的用户名为:" + userName);
            }
            else
            {
                Response.Write("你的用户名为空");
            }
            string userPWD = Request.Form.Get("pwd");
            if (userPWD != null)
            {
                Response.Write("你的密码为:" + userPWD);
            }
            else
            {
                Response.Write("你的密码名为空");
            }
    我这样写了,结果是:你的用户名为空你的密码名为空
    那么我在文本框中写的值到哪去了??
      

  13.   


    Request.Form["tetUserName"]这样多简洁啊!