Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:16:34+00:00 2026-06-02T04:16:34+00:00

I’ve an asp repeater which has some fields inside an ItemTemplate. Each item in

  • 0

I’ve an asp repeater which has some fields inside an ItemTemplate. Each item in the repeater has an “add to cart” asp:ImageButton and an invisible asp:Label as well. The code looks like this:

<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="addToCart">
        <HeaderTemplate>
            <table id="displayTable"> 
        </HeaderTemplate>
        <ItemTemplate>
           <td>
                <!-- fields like name, description etc in the repeater are present; i've omitted to show them here-->
                <asp:Label ID="addedToCartLabel" runat="server" Visible="false"></asp:Label>       
                <asp:ImageButton ID="addToCartImg" runat="server" ImageUrl="hi.jpg" Width="75px" Height="50px" />
           </td>
        </ItemTemplate>
        <FooterTemplate>
           </table>
        </FooterTemplate>
</asp:Repeater>

When a particular ImageButton in the repeater is clicked, I’m trying to display “added to cart” as the text of its corresponding Label, and make the clicked ImageButton Visible=false. I’ve tried using the OnItemCommand function for the ASP:Repeater. The method is “addToCart”:
<>

void addToCart(Object Sender, RepeaterCommandEventArgs e)
{
    Cart cart = new Cart();
    cart.instrument_id = //id of product from repeater based on user click
    String userName = Membership.GetUser().ToString();
    cart.user_name = userName;
    cart.quantity = 1;
    var thisLbl = (Label)e.Item.FindControl("addedToCartLabel");
    var thisImg = (ImageButton)e.Item.FindControl("addToCartImg");
    try
    {
        database.Carts.InsertOnSubmit(cart);
        database.SubmitChanges();

        thisImg.Visible = false;
        thisLbl.Text = "Added to Cart!";
        thisLbl.Visible = true;

    }
    catch (Exception ex)
    {
        thisImg.Visible = false;
        thisLbl.Text = "Processing failed;please try again later";
        thisLbl.Visible = true; ;
    }


}

The aspx page is populated properly. However, when I click on any of the ImageButtons in the repeater, I get the following error:

  Server Error in '/mysite' Application.
    Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. 
If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback
or callback data for validation.

Can someone help me with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:16:36+00:00Added an answer on June 2, 2026 at 4:16 am

    May I suggest doing this with client-side javascript rather than a server-side call?

    <asp:Label ID="addedToCartLabel" runat="server" Visible="false"></asp:Label>       
    <asp:ImageButton ID="addToCartImg" runat="server" ImageUrl="hi.jpg" Width="75px" Height="50px" />
    

    becomes

    <asp:Label ID="addedToCartLabel" runat="server" Visible="false"></asp:Label>       
    <asp:ImageButton ID="addToCartImg" runat="server" onclick="javascript:function() { this.this.style.display='none'; document.getElementById(this.parentNode.firstChild.id).style.display='block'; }"  ImageUrl="hi.jpg" Width="75px" Height="50px" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.