仅当我将文件上传到服务器但代码在我的本地主机中运行良好时,我才收到有关代码的错误

时间:2016-04-26 01:44:39

标签: sql-server visual-studio-2012

我在visual studio中使用asp.net并且我有一个代码以我的本地成本工作但是当文件被加载到服务器然后我收到服务器错误

Server Error in '/' Application.

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.mytasks_aspx' does not contain a definition for 'linkButton2_Click' and no extension method 'linkButton2_Click' accepting a first argument of type 'ASP.mytasks_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 98:                  <asp:TemplateField ShowHeader="False" HeaderText="TaskID" >
Line 99:                      <ItemTemplate>
Line 100:                         <asp:LinkButton ID="LinkButton2" OnClick="linkButton2_Click" runat="server" CausesValidation="false" CommandName="" Text='<%# Eval("TaskID") %>'></asp:LinkButton>
Line 101:                     </ItemTemplate>
Line 102:                 </asp:TemplateField>

这是我得到的错误,我使用的代码是

CS文件中的

:使用方法

 protected void linkButton2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/View.aspx?TaskID=" + ((LinkButton)sender).Text);
        }

在设计页面中,这是存在的代码:

 <asp:TemplateField ShowHeader="False" HeaderText="TaskID" >
                     <ItemTemplate>
                         <asp:LinkButton ID="LinkButton2" OnClick="linkButton2_Click" runat="server" CausesValidation="false" CommandName="" Text='<%# Eval("TaskID") %>'></asp:LinkButton>
                     </ItemTemplate>
                 </asp:TemplateField>

1 个答案:

答案 0 :(得分:0)

尝试将本地的所有更新上传到您的服务器,特别是ASPX和项目的DLL,并在查找文件时使用相对路径,如果它在您本地工作,它也应该在您的服务器中工作,谢谢