Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET C# Repeater - How to pass information back to server without Javascript?
    primarykey
    data
    text
    <p>I'm learning C# and working on my first ASP.Net e-commerce website.</p> <p>I have the following repeater:</p> <pre><code>&lt;asp:Repeater ID="Cartridges" runat="server" OnItemCommand="Cartridges_ItemCommand"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="buy" runat="server" CommandName="AddtoCart" CommandArgument=&lt;%#Eval("cartID") %&gt; Text="Buy"&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; </code></pre> <p></p> <p>However, when the code is rendered the repeater produces JavaScript to postback which is no good when populating a shopping cart if the user has JavaScript turned off!</p> <pre><code>&lt;div class="wrap-cart"&gt; &lt;div class="cartbuy"&gt;&lt;a id="ContentPlaceHolder1_Cartridges_buy_0" href="javascript:__doPostBack(&amp;#39;ctl00$ContentPlaceHolder1$Cartridges$ctl00$buy&amp;#39;,&amp;#39;&amp;#39;)"&gt;Buy&lt;/a&gt;&lt;/div&gt; &lt;div class="cartimg"&gt;&lt;a href="url.html" class="productsurl"&gt;&lt;img src="pic/epson-comp-set50.jpg" alt="product" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="carttext"&gt; &lt;p class="cartdesc"&gt;&lt;a href="url.html" class="productsurl"&gt;&lt;span class="homeprinters"&gt;product&lt;/span&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="cartprice"&gt;£x.xx&lt;/p&gt; &lt;/div&gt; </code></pre> <p></p> <p>All I want to do is to pass the cartID to a data table. Is there a way round it so JavaScript is not involved at all?</p> <p>For completeness here's my code behind:</p> <pre><code>protected void Cartridges_ItemCommand(object source, RepeaterCommandEventArgs e) { cartidtest.Text = "added"; if (e.CommandName == "AddtoCart") { string varCartID = (e.CommandArgument).ToString(); //more code here } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload