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

  • Home
  • SEARCH
  • 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 6623389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:31:38+00:00 2026-05-25T21:31:38+00:00

I have a session variable that changes some things about how a page looks.

  • 0

I have a session variable that changes some things about how a page looks. I have a button that changes the value of this session variable. But … the onClick event happens after page load, so by the time I update the session variable based on the button click, it’s too late, the page has already been loaded.

Theoretically I could put all the logic about changing the display into a function and call it from page load, and then call it again from the onclick after the variable as been updated. But this is impractical: there are many user controls that check the value, used on many different pages in different combinations. I would have to hard-code the list of user controls on each page, and if someone added a new user control to a particular page, they’d have to remember to update this function, which is lame.

Is there a way to force a page reload? (I can use response.redirect back to myself and it works. If all else fails I guess this is what I’ll do. But it means an extra round trip to the server, which is clumsy.)

Is there a way to process the onclick before the page load?

Some other magic solution?

  • 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-25T21:31:38+00:00Added an answer on May 25, 2026 at 9:31 pm

    If you have to change the look and feel of a page based on a specific value which can change, then you should have dedicated functions that set up the look and feel in a single unified place, and then you call those functions in every case where a value that affects the look and feel is called.

    Examples:

    private void SetDivVisibility()
    {
      // display logic here based on variables
    
    }
    
    private void MyControl_Click(...)
    {
       myvalue = blah;
       SetDivVisibility();
    }
    

    It helps to bear in mind that the actual rendering of the page is last thing that happens, after both page load AND event processing.

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

Sidebar

Related Questions

We have various related session variables for a complex page that has various things
So there are a few things I know about this topic but I am
I am currently in C# and I have set Session variables on each page.
I have a session class that needs to store session information in a MySQL
Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:
I have an NHibernate session. In this session, I am performing exactly 1 operation,
I have read about session fixation and from what I understand it forces a
I have an external log file which name changes each session, with the format
I have a JSP page that renders, and calls a Web service to load
I have a shopping cart flow like this: Page 1 . Choose Products Page

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.