I am learning C # and working on my first ASP.Net e-commerce site.
I have the following repeater:
<asp:Repeater ID="Cartridges" runat="server" OnItemCommand="Cartridges_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="buy" runat="server" CommandName="AddtoCart" CommandArgument=<%#Eval("cartID") %> Text="Buy"></asp:LinkButton>
</ItemTemplate>
However, when the code is rendered, the relay creates JavaScript for postback, which is not suitable when filling out a shopping cart if the user has disabled JavaScript!
<div class="wrap-cart">
<div class="cartbuy"><a id="ContentPlaceHolder1_Cartridges_buy_0" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Cartridges$ctl00$buy','')">Buy</a></div>
<div class="cartimg"><a href="url.html" class="productsurl"><img src="pic/epson-comp-set50.jpg" alt="product" /></a></div>
<div class="carttext">
<p class="cartdesc"><a href="url.html" class="productsurl"><span class="homeprinters">product</span></a></p>
<p class="cartprice">£x.xx</p>
</div>
All I want to do is pass the cartID to the data table. Is there a way around it, so JavaScript is not involved at all?
For completeness, here is my code behind:
protected void Cartridges_ItemCommand(object source, RepeaterCommandEventArgs e)
{
cartidtest.Text = "added";
if (e.CommandName == "AddtoCart")
{
string varCartID = (e.CommandArgument).ToString();
}
}
source
share