我在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>
答案 0 :(得分:0)
尝试将本地的所有更新上传到您的服务器,特别是ASPX和项目的DLL,并在查找文件时使用相对路径,如果它在您本地工作,它也应该在您的服务器中工作,谢谢