各位大哥
为什么我在login类中定义了一个txt控件
然后在后台String aa=this.TextBox1.Text;
说我login类并不包含TextBox1?
我明明在这个类的显示拖放了这个控件
为什么还说没定义
如果我没定义为什么还能this.出来这个控件的名字??
奇怪啊
希望高人解答

解决方案 »

  1.   

    </table>
    <!--控件声明区域结束-->
        </div>
         <asp:Panel ID="Panel1" runat="server" Height="138px" Width="200px">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></asp:Panel>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" popupcontrolid="Panel1"  targetcontrolid="Panel1" BackgroundCssClass="modalBackground" OkControlID="">
        </cc1:ModalPopupExtender>
        </form>
       
    </body>
    </html>
    前台的代码
    很奇怪
    在这个界面上拖放任何控件
    后台都能this得到
    但是为什么就是说本类未定义
      

  2.   

    你那个this不是login类的对象吧,可能是Page页面.
      

  3.   

    直接FindControl("控件名") 算了
      

  4.   

    FindControl("控件名") 就是未将对象引用到实例了
    跑起来侯
    点击按钮的时候
      

  5.   

    TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1");
            String aa= tb.Text;
            
            Response.Write("<script>alert(aa);</script>");
    代码如上
      

  6.   

    Control c=this.form1.controls.findcontrol("TextBox1");
      

  7.   

      &nbsp; &nbsp; &nbsp;&nbsp;
            <br />
            <br />
            <br />
            <br />
            <br />
            &nbsp;<asp:Panel ID="Panel1" runat="server" Height="57px" Width="621px" >
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></asp:Panel>
            <br />
            <br />
            <br />
     TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1");
            String aa= tb.Text;
            
            
            Response.Write("<script>alert(aa);</script>");我就是想在这个按钮下得到这个txt并且要给数据库插值
    但是都不行
    直接this.也不行
    高手帮忙谢谢了
      

  8.   

    是啊
    别人写的这个类
    我是修改
    这个类
    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 System.Runtime.InteropServices;public partial class admin_ShowAgent : System.Web.UI.Page
    {
    是继承了
      

  9.   

    先打扰一下吧.你上回结的贴子, 用了我的代码不是不好使吗?我上传了一个我贴的代码一模一样的. 你看一下:http://ybyztcd.com/temp/default.aspx
      

  10.   

    你这个问题很严重
    重新扔一个textbox试一下