Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I typically store things like menu state or filter (set of inputs in a div) visibility, etc. server-side in the session via AJAX. When a menu expands or a filter is shown, the click handler will fire an AJAX event to a web service that will record the state of the menu or filter visibility in the user's session. On a postback I use the session variables corresponding to each menu/filter to set it's initial state via CSS. I find that this is better user experience since the page doesn't <em>flash</em> when it is updated by javascript after loading if you make the changes client-side.</p> <p>Example -- as I'm on the road this not actual code from a project and may be incomplete. Uses jQuery. The Url for the web service is going to depend on how you implement web services. I'm using ASP.NET MVC (mostly) so mine would be a controller action.</p> <pre><code>&lt;script type='text/javascript'&gt; $(document).ready( function() { $('#searchFilter').click( function() { var filter = $(this); var filterName = filter.attr('id'); var nowVisible = filter.css('display') === 'none'; if (nowVisible) { filter.show(); } else { filter.hide(); } $.post('/controller/SetFilterVisibility', { name: filterName, visibility: nowVisible } ); }); }); &lt;/script&gt; &lt;div id='searchFilter' &lt;%= ViewData["searchFilterVisibility"] %&gt; &gt; ... &lt;/div&gt; </code></pre> <p>Server-side code</p> <pre><code>[AcceptVerbs( HttpVerbs.POST )] [Authorization] public ActionResult SetFilterVisibility( string name, bool visible ) { Session[name] = visible; return Content( string.Empty ); // not used... } [AcceptVerbs( HttpVerbs.GET )] [Authorization] public ActionResult SomeAction( int id ) { ... ViewData["searchFilterVisibility"] = Session["searchFilter"]; ... return View(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload