当我将LinkButton
事件放入其中时,我在OnClick
标记中出错。
<asp:LinkButton ID="btngo" runat="server" CommandArgument='<%# Eval("Blog_ID") %>' Text="More" Font-Size="Smaller" OnClick="btngo_Click" ForeColor="#3366cc"></asp:LinkButton>
在后面的代码中,我有像这样的代码
protected void btngo_Click(object sender, EventArgs e)
{
int id = int.Parse((sender as LinkButton).CommandArgument);
Response.Redirect("Blog-Post.aspx?BID=" + id);
}
它说
CS1061: 'ASP.blog_aspx' does not contain a definition for 'btngo_Click' and no extension method 'btngo_Click' accepting a first argument of type 'ASP.blog_aspx' could be found (are you missing a using directive or an assembly reference?)
任何解决方案?
答案 0 :(得分:4)
在您的aspx代码更改的第一行
代码隐藏=&#34;&#34;
到
CodeFile =&#34;&#34;