How to Avoid Losing the State of Controls in ASP.NET MVC -


i'm working asp.net mvc 2 , building simple business app. here of details:

  • the app deals work orders , has work order index view. view has table listing work orders, , several controls (text boxes, check boxes, , drop down lists) select criteria work orders display.

  • i'm using viewmodels. work order index view has viewmodel properties each , every control.

  • i've implemented paging similar being done in answer question: how do pagination in asp.net mvc? i'm using linq's skip() , take() demonstrated, , actionlinks navigation.

  • if load page , don't manipulate of controls, can click on page number actionlinks , move around fine between pages of work orders. however, if change something, changes lost when navigate page.

    for example, if i'm on page 1 , click unchecked check box, , click on link page 2, second page of results load check box revert previous state.

i understand why happens, i'm wondering best thing design standpoint.

potential solutions can think of:

  1. set control values route values in actionlinks. seems nasty, , result in long urls or query strings. actually, think of wouldn't work without way capture control values.

  2. since actionlinks don't post anything, replace them buttons. again, seems bad idea.

  3. change actionlinks links fire off jquery script post. think promising option far. many developers way?

this seems common enough problem, none of these options feel quite right. wonder if i'm missing something.

can't save changes database when user toggles checkboxes (using jquery):

$("input[type=checkbox]").click(function() {      $.ajax({           type: "post",           url: "/controllername/saveinfo?id=" + {id},           success: function(){                 alert("data saved: " + msg);           }      }); }); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -