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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:20:01+00:00 2026-05-12T17:20:01+00:00

I have a method that list listing directories and you can drill in the

  • 0

I have a method that list listing directories and you can drill in the directories. The method looks like this:

           public ActionResult ListObjects(string Prefix)
           {
             if(string.isnullorempty(Prefix))
                //Present root files and directories
             else
                //Present directory choosed with Prefix
           }

On the view ListObjects, I am experiencing the Prefix hidden field not changing value after the first time it has a value. I proofed that by adding and extra field that does changes the value after the first time it has one. for example: the first time you process the listobjects method prefix is null, and item.prefix has the first value for each directory, but after you click on any directory in the first view, the second time the controller is called the actual value never changes.

                <%= Html.Hidden("Prefix",item.Prefix) %>
                <%= Html.Hidden("TestVariable" ,item.Prefix) %>

This is a little proof of what is actually happening.

   <input id="Prefix" type="hidden" value="CP/" name="Prefix"/>
   <input id="TestVariable" type="hidden" value="CP/CPTest/" name="TestVariable"/>

My objective is to have the input id=”Prefix” to change in every call, and not stay static after the first time it gets a value. As you can see the two input fields above the Prefix has CP while the testvariable has cp/cptest which is the value that I wanted, but both input fields are being taken from the same variable.

EDIT 2:

I think it has to do with the fact that strings are references and since mvc framework sees that Prefix has a value from a previous request it overrides the new value assignment from model.Prefix.


NOTE: I posted the question yesterday, and I answer the question myself after a little troubleshooting. The solution that I found is not the ideal, but is working and I am done unless someone here is able to give me a better way of achieving the same. Please let me know. Geo

  • 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-12T17:20:02+00:00Added an answer on May 12, 2026 at 5:20 pm

    I am sure this is not the ideal solution, but I got around my issue by not using the MVC helper files. Instead of using the Html.Hidden helper I used directly the input field as below:

      <%--<%= Html.Hidden("Prefix",item.Prefix) %>--%>                
      <input id="Prefix" type="hidden" value="<%= item.Prefix %>" name="Prefix" />  
    

    This works like a charm, if you think of a reason why the html.Hidden is not working please let me know.

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

Sidebar

Related Questions

I have a method that returns a list of type string. I want to
All, I have a method that returns a List. This method is used to
I have a class that wraps List<> I have GetValue by index method: public
I have a method that takes a list of entities ( Class es) and
Scenario I have a method that returns a list of processes using WMI. If
I have a method that returns a new list (it pertains to a multiple
I'm new to Python. I have a method that begins: def foo(self, list): length
I have a generic Print method that iterates over a list and simply prints
In .NET, both array and list have Enumerable as ancestor, so a method that
I have a method I'm writing that uses reflection to list a class's static

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.