不包含asp.net页中的按钮单击事件的定义错误 [英] Does not contain definition error for Button click event in asp.net page

查看:79
本文介绍了不包含asp.net页中的按钮单击事件的定义错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在edit.aspx页面上有一个带有以下代码的按钮

i have a button in edit.aspx page with below code

<asp:Button ID="GoButton" runat="server" Text="Go" onclick="GoButton_Click" />

然后page指令如下

<%@ Page language="c#"  EnableEventValidation="false" Codebehind="AdminHotelEdit.aspx.cs" AutoEventWireup="false" Inherits="GTIAdmin.AdminHotelEdit" ValidateRequest="false"%>

并且我在文件后面的代码中定义了按钮单击事件,如下所示

and i have the button click event defined in code behind file as follows

public void GoButton_Click(object sender, EventArgs e)
{
}

当我的调试程序出现错误提示时

when i debug program is getting error stating that

Error   146 'ASP.edit_aspx' does not contain a definition for 'GoButton_Click'
and no extension method 'GoButton_Click' accepting a first argument of type
'ASP.adminhoteledit_aspx' could be found (are you missing a using directive or an
assembly reference?)    

如果您对这个错误的原因有任何了解,请提出建议.

please suggest me if you have idea about the reason of this error.

edit.cs中的代码如下

the code in edit.cs is as follows

namespace GTIAdmin
{
    /// <summary>
    /// Summary description for AdminHotelEdit.
    /// </summary>

    public class AdminHotelEdit : GTIAdminPage
    {
        protected Button GoButton_Click;

        private void Page_Load(object sender, System.EventArgs e)
        {

        }

        public void GoButton_Click(object sender, EventArgs e)
        {

        }
    }
}

推荐答案

向我们展示'Edit.aspx.cs'的内容

Show us the contents of 'Edit.aspx.cs'

-

继承"字段为空白.将其设置为"Edit.aspx.cs"中类的名称,生活应该会很好.

The 'inherits' field is blank. Set it to the name of the class in 'Edit.aspx.cs' and life should be good.

-再次

不.这是因为AutoEventWireup为false.

Nope. It's because AutoEventWireup is false.

这篇关于不包含asp.net页中的按钮单击事件的定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆