serialization - How do I process a serialized string in ASP.NET MVC? -


i haven't worded title of question particularly in slightest.

i'm bit of newbie when comes lot of json bits , pieces , currently, have nested sortable plugin produces following serialized string:

list[1]=root&list[2]=root&list[3]=2&list[4]=2&list[5]=2&list[6]=2&list[7]=root&list[8]=root&list[9]=root&list[10]=root&list[11]=10&list[12]=10&list[13]=10&list[14]=10&list[15]=root&list[16]=root

which , good, i've not clue how process in controller. i've had google , couldn't find specific, think search terms poorly worded question title.

can point me in right direction please?

thanks in advance.

this how in mvc 2. edit: use json2.js script mentioned in haacked article

part of html:

 <ul class="sortlist">     <% foreach(var item in model){ %>      <li  id="item_<%= item.id %>"> 

the jquery:

 $(".sortlist").sortable(         {             connectwith: ".sortlist",             containment: "document",             cursor: "move",             opacity: 0.8,             placeholder: "itemrowplaceholder",             update: function(event, ui) {                 $.post("/admin/updatesortorder/", { sortlist: $(this).sortable("serialize") });             }         }); 

the value being posted:

"item_0d2243bf-e01d-4049-964c[]=d69b92009072&item_bab23d45-442b-4178-817c[]bbdea32ff226&item_e987ed37-cf30-4413-8687[]=9dc8d111482a" 

the action

[httppost]         public actionresult updatesortorder(string sortlist)         {             string[] separator = new string[2] { "item_", "&" };             string[] temparray = sortlist.split(separator, stringsplitoptions.removeemptyentries);              if (temparray.length > 0)             {                 (int = 0; < temparray.length; i++)                 {                     temparray[i] = temparray[i].replace("[]=", "-");                     guid _id = new guid(temparray[i]);                     var temp = _session.single<photo>(x => x.id == _id);                     temp.sortorder = + 1;                     _session.update(temp);                     _session.commitchanges();                 }              } return content("volgorde aangepast");         } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -