0

我的 button1 onclick 事件有问题,

它在我的本地计算机上运行良好,但是,当我发布到服务器时它显示错误:

>     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.resourcecenter_default_aspx' does not contain a definition for 'Button1_Click' and no extension
> method 'Button1_Click' accepting a first argument of type
> 'ASP.resourcecenter_default_aspx' could be found (are you missing a
> using directive or an assembly reference?)
>     
>     Source Error:
>     
>     
>     Line 66:         <tr>
>     Line 67:         <td class="style1">
>     Line 68:         <asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" />
>     Line 69:
>     Line 70:         </td>

这是我的代码:

aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

......

<tr>
        <td class="style1">
        <asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" />

</td>

C#:

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

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string sqlcode = null;
            string request = TextBox2.Text.ToString();
.....}

谁能帮我弄清楚发生了什么?我真的很感谢你的帮助!

4

1 回答 1

0

您可以尝试将 _Default 类封装在一个唯一的命名空间中,或者更改类名,以防它与您网站中在其后面的代码中具有相同类名 (_Default) 的另一个页面发生冲突。

于 2012-07-23T14:57:53.367 回答