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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:17:22+00:00 2026-05-19T22:17:22+00:00

I have stumbled upon the issue when I need to retract html controls I’ve

  • 0

I have stumbled upon the issue when I need to retract html controls I’ve added client-side using JavaScript after the postback (due to server-side validation – this is not optional).

Please tell me if the way I’m trying to achieve this is cr*p and there’s a better way of doing this.

basically, what I’m doing is cloning a textbox control for up to 10 times on the page when the user hits “Add” and storing entered values from each of those texboxes in a hidden field to read from in the code behind. This works fine, however, when the server side validation doesn’t pass after postback, all those dynamically added (cloned) texboxes disappear, since ViewState knows nothing about them.

I am considering 2 possible solution, both of which seem hacky:

  • Rebuild all cloned textboxes on document onload() using stored values in the hidden field

  • wrap the form in ajax update panel and place the cloned texboxes outside of it, thus, not refreshing this part of the screen on postback

now, is it possible to somehow “update” ViewState to make it aware of all the html controls I’ve added using client-side script? Any better ideas? I’d like to achieve this with client-side script, therefore not considering cloning textboxes on server-side, sorry.

  • 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-19T22:17:23+00:00Added an answer on May 19, 2026 at 10:17 pm

    You cannot modify the ViewState on the client side. If you do, you will invalidate the viewstate and receive an error on the postback.

    In your case you might want to consider using javascript and jQuery to render the text boxes on the document ready event with the values stored in your hidden field. I’d recommend taking a look at jQuery templating, particularly if you can store your data as JSON in the hidden field (http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery-plugins.aspx).

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

Sidebar

Related Questions

I'm hoping someone happens to have stumbled upon the following issue before. My Java
I'm revisiting som old code of mine and have stumbled upon a method for
I have stumbled into several methods of looping in JavaScript, what I like the
I have stumbled upon a situation where I cannot start more than a certain
I stumbled upon an issue with event namespacing while developing a jQuery plugin. here
I have stumbled upon a bug in Safari on iPad. $('#next_proj a').trigger('click'); .. does
I have stumbled upon a problem when adding a button to my table view
I have just stumbled upon Bad Behavior - a plugin for PHP that promises
Recently, I have stumbled upon the basic understanding about PKI work-in-action process. I have
I just stumbled upon this issue and i can't think of a solution I

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.