后端(Aspx.CS)此事件未触发
protected void btnCart_Click(object sender, EventArgs e)
{
Button b = sender as Button;
if(b!=null)
{
name = b.CommandArgument;
Response.Redirect("/Cart.aspx");
}
}
前端(Aspx代码):
<asp:DataList ID="ItemList" runat="Server" CaptionAlign="Right" RepeatColumns="4" Width="100%" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Bind("Image")%>' alt='Image Not Visible' Style="height: 200px; width: 200px;" />
<div class="caption">
<h4>
<asp:Label ID="ufname" runat="server" Text='<%#Bind("Name") %>'>l</asp:Label></h4>
<p class="text-success">Rs:<asp:Label ID="ufprice" runat="server" Text='<%#Bind("Money") %>'></asp:Label></p>
<p>
<asp:Button ID="btnCart" CssClass="btn btn-primary" runat="Server" Text="Buy Now" CommandArgument='<%# Eval("Id") %>' OnClick="btnCart_Click"/>
<asp:Button ID="Veiw" runat="server" CssClass="btn btn-danger" Text="Details.." CommandArgument='<%# Eval("Id") %>' OnClick="btnCart_Click" />
</p>
</div>
</ItemTemplate>
答案 0 :(得分:1)
您是否将EnableEventValidation设置为false? 你使用任何类型的UpdatePanel吗?