没有'DisplayBox_TextChanged'的定义

时间:2011-07-24 01:51:18

标签: c# error-handling

Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'ASP.calculator_aspx' does not contain a definition for 'DisplayBox_TextChanged' and no extension method 'DisplayBox_TextChanged' accepting a first argument of type 'ASP.calculator_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:enter code here

Line 18:     <tr>
Line 19:         <td colspan="5">
Line 20:             <asp:TextBox ID="DisplayBox" runat="server" 
Line 21:                 ontextchanged="DisplayBox_TextChanged" Width="268px"></asp:TextBox>
Line 22:         </td>
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class calculator : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

4 个答案:

答案 0 :(得分:1)

如果要支持DisplayBox的TextChanged事件,请在.cs文件中实现DisplayBox_TextChanged事件。

protected void DisplayBox_TextChanged(object sender, EventArgs e)
{
    //logic...
}

如果您对TextChanged事件不感兴趣,请从XAML文件中删除以下部分(第21行)。

ontextchanged="DisplayBox_TextChanged"

答案 1 :(得分:0)

从您提供的一小段代码中可以看出,您正在尝试响应ontextchanged事件,但您没有实现DisplayBox_TextChanged方法来处理事件。从上面的代码中删除ontextchanged="DisplayBox_TextChanged或创建一个名为DisplayBox_TextChanged

的方法

答案 2 :(得分:0)

在您的代码隐藏文件中,您需要实现DisplayBox_TextChanged方法。

它看起来像这样

protected void DisplayBox_TextChanged( EventArgs e )
{
    //code here
}

方法的MSDN http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.ontextchanged(v=VS.90).aspx

答案 3 :(得分:-1)

试试这个:

  

从项目浏览器右键单击项目并选择添加引用并添加dll文件StructureMap.dll它可能位于项目的bin目录中

http://forums.asp.net/t/1381741.aspx/1

JMAX