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 712561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:51:42+00:00 2026-05-14T04:51:42+00:00

In the project I’m working on I have got a list List<Item> with objects

  • 0

In the project I’m working on I have got a list List<Item> with objects that Is saved in a session. Session.Add("SessionName", List);

In the Controller I build a viewModel with the data from this session

var arrayList = (List<Item>)Session["SessionName"];
var arrayListItems= new List<CartItem>();

foreach (var item in arrayList)
            {
                var listItem = new Item
                                   {
                                       Amount = item.Amount, 
                                       Variant= item.variant, 
                                       Id = item.Id
                                   };
                arrayListItems.Add(listItem);

            }

var viewModel = new DetailViewModel
            {
                itemList = arrayListItems
            }

and in my View I loop trough the list of Items and make a form for all of them to be able to remove the item.

<table>
    <%foreach (var Item in Model.itemList) { %>
       <% using (Html.BeginForm()) { %>
           <tr>     
              <td><%=Html.Hidden(Settings.Prefix + ".VariantId", Item .Variant.Id)%>
              <td> <%=Html.TextBox(Settings.Prefix + ".Amount", Item.Amount)%></td>
              <td> <%=Html.Encode(Item.Amount)%> </td>
              <td> <input type="submit" value="Remove" /> </td>
           </tr>
      <% } %> 
    <% } %> 
</table>

When the post from the submit button is handeld the item is removed from the array and post back exactly the same viewModel (with 1 item less in the itemList).

return View("view.ascx", viewModel);

When the post is handled and the view has reloaded the value’s of the html.Hidden and Html.Textbox are the value’s of the removed item. The value of the html.Encode is the correct value. When i reload the page the correct values are in the fields. Both times i build the viewModel the exact same way.

I cant find the cause or solution of this error. I would be very happy with any help to solve this problem

Thanx in advance for any tips and help

  • 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-05-14T04:51:43+00:00Added an answer on May 14, 2026 at 4:51 am

    This happens because you are posting back to the same URL. ASP.NET has a built in mechanism to make sure that values from form inputs are always returned to the browser the same as they are sent in when posting back to the same URL. This can be a very annoying behavior, I agree, but there is likely a lengthy discussion of rationale for it somewhere. For starters, it would break the auto populate with same values on validation feature of ASP.NET.

    The easiest way I have found to get past the problem is to just post to a different URL and redirect back. You can also fix the problem by handling the request via AJAX.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The project that I am working on (Node.js) implies lots of operations with the
My project is ARC enabled (the build settings have Objective-C Reference Counting set to
Project Requirements: I need to build a web service that will receive chunks of
Project I'm working on uses jQuery. I have a series of Ajax calls being
Project is C#. So I have a bunch of multithreaded code that is designed
Project Structure I have a silverlight project SLProj, that references a silverlight class library
project type is MVC2. Let say that i have page1. after success it write
Project: http://design.vitalbmx.com/fave/news.html When I click Add to favorites button (under main pic), in Chrome
My project consists of an app that links to two static libraries. Each of
The project currently has a UIviewController called Dashboard that acts as the main view

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.