WindowsApplication1.Form1.Dispose(bool) 没有找到适合的方法来重写
这个错误应该怎么改啊?网上有人说要把Form1.cs和Form1.Designer.cs命名空间名称改成一样的,可是我改完还是不行!
源码如下:
using System;
using System.Data;
using System.Configuration;
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;namespace WindowsApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //创建一个文本框
            TextBox tbxName = new TextBox();
            tbxName.ID = "tbxName";
            tbxName.Text = "OK";
            this.form1.Controls.Add(tbxName);            //创建一个按钮
            Control c = ParseControl("<asp:Button Text = '按我' ID = 'myButton' runat = 'server' />");
            this.form1.Controls.Add(c);            //创建一个按钮事件
            Button myButton = (Button)Page.FindControl("myButton");
            myButton.Command += new CommandEventHandler(this.myButton_Click);        }        protected void myButton_Click(Object sender, EventArgs e)
        {
            
            TextBox t = (TextBox)Page.FindControl("tbxName");
            Response.Write(t.Text);
        }    }
}以下是Form1.Designer.cs的代码:namespace WindowsApplication1
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }        #region Windows 窗体设计器生成的代码        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Text = "Form1";
        }        #endregion
    }
}

解决方案 »

  1.   

    namespace WindowsApplication1 

        partial class Form1 :Form
      

  2.   

    namespace WindowsApplication1 

        partial class _Default 
      

  3.   

    这两个文件不是同一个类!类名不相同。直接把partial class Form1 里的内容拷到你的Default 类里就行了
      

  4.   

    你是不是修改过命名空间?
    这问题经常有的把窗口的.DESIGNER.CS文件的命名空间改成和你.CS的命名空间一样就好了