Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    how to page with original hidden input settings

    Hi,

    I have a page that the hidden input fields and their values are written by a server side script (aspx). These input fields and their values are passed to some javascript during the body onload event to set visual elements. The user can change some of the visual elements by clicking on them to turn them "on". Everything seems to work like I want it to, with one exception. And that is if the page is reloaded. If a user selects an element by clicking on it, causing it to change to "on", and if the page is reloaded, that same element stays on, when it was originally off.

    Any ideas on how to avoid this?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    Two ways:

    (1) Change the values of the hidden fields and SUBMIT the page back to the ASP.NET code. Have the ASP.NET code save those field values (in a database?) and so, when the user reloads the page, he gets back his changed values.

    (2) Use cookies. Store the changed values in cookies, via JavaScript. When the page is reloaded from the server, see if there are any changed values saved in cookies. If so, let the cookie values overwrite the values from ASP.NET *before* the JavaScript use the values to set the visual elements.

    There is also a (2-A): ASP.NET can read the cookies that JavaScript set, so you could have the ASP.NET code read the cookies and change what it puts into the hidden fields.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, that isn't exactly what I was talking about.

    What I'm talking about is not a postback to the server. When the page first loads, it is set to display visual elements in a certain way. Users select images, which causes the image position to change through an onclick event client side. during this user selection process, there is not a postback to the server. Now, there will be a postback button that a user can click once the selection process is completed to the satisfaction of the user.

    But what I'm trying to figure out is if during the selection process, before the actual postback, the user decides to reload the page, how can I prevent the newly loaded page from reading the previously loaded page's post array, and get the hidden input settings as they came from the server?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    <shrug>See my answer (2).</shrug>

    Best I can suggest.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, Thanks for your time and consideration.

    Looking at your avatar, I take it that your a rail fan. One project that I would like to do someday is to make an interactive map of the old lines. Something really nice, and kind of point out each line's notable trains or locos. May be some day.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    Would be fun. Would you "age" it? That is, allow the user to pick a year and show the lines that existed in that year? I was looking at a map of lines as of the start of the Civil War. What a mess of spaghetti.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    nakins (05-14-2013)

  • #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    without seeing any code, it sounds like you have some visual form elements that control the page's look, and that those visual controls are set from hidden controls. most browsers persist any form value changes the user makes before a reload. this prevents lost form info. if the visual controls are not synced to the hidden inputs, chaos ensues.

    if you can post a bit of the code that's cause trouble we can help you much better.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • Users who have thanked rnd me for this post:

    nakins (05-14-2013)

  • #8
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Would be fun. Would you "age" it? That is, allow the user to pick a year and show the lines that existed in that year? I was looking at a map of lines as of the start of the Civil War. What a mess of spaghetti.
    Wow, that would be a challenge, collecting all that data and trying to display that. I don't know if I would do it be year. Maybe by period, like pre Civil War, Civil War to Golden Spike, Golden Spike to the beginning of WWI, WWI to the the Crash. WWII, Post WWII, the the fall.

    I moved around a lot when I was a kid in the 60's. One place we live was Cheyenne, Wyo., which had a Big Boy on display at a city park, and a yearly celebration called "Hell on Wheels.". And I was living there during the 100th Golden Spike anniversary. which was fun. And my then living grandfather had worked for Rock Island. I would visit during the summer and from the house, the Rock Island track ran behind the house about ten minute walk. Further back was the Missouri Pacific. But, across the street was a short line that ran from Pine Bluff to a nearby wood mill. And they still used a steam locomotive the first time I came to stay for the summer. I think Cotton Belt bought the line in the mid 60's and ran a diesel switcher, like those curved roof Alco's. But, hearing that steam loco rumble through the woods was awesome. I with my mother made three passenger train trips to Arkansas when I kid. Two were on UP/MP from Cheyenne, and one from Grand Forks to Chicago to Memphis to Little Rock. Chicago to Little Rock was the Texas Eagle. I'm not sure was the ride from Grand Forks to Chicago was. Could have very well been GN or NP. All that being said, I have a fondness for the passenger trains.

    Wish I had the money to have collected HO models. Anyway, What's your rail story? If you got any ideas about websites and railroads, would love to hear them.

  • #9
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I'm trying to get a domain name issue straighten out. Once I get that done, hopefully tomorrow, I can upload the code there. But, you are correct in that the initial settings for the hidden input values are set server side, and through user input, they change before postback.

    Quote Originally Posted by rnd me View Post
    without seeing any code, it sounds like you have some visual form elements that control the page's look, and that those visual controls are set from hidden controls. most browsers persist any form value changes the user makes before a reload. this prevents lost form info. if the visual controls are not synced to the hidden inputs, chaos ensues.

    if you can post a bit of the code that's cause trouble we can help you much better.

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Try doing a form reset on page load. That will always reset the form elements to default state.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •