However i felt that in the long run, having the toggle run on the server would be better for this particular situation.
Webmatrix is the Microsoft development platform that uses razor syntax. I ultimately found the solution by slightly modifying a helper routine published by Mike Brind, Imar Spaanjaars in the book that I purchased “Beginning ASP.net web Pages with WebMatrix”. WebmMatrix has evolved but the @helper code still works. Using that original code as the basis, I came up with a slightly modified, special ‘toggle version’. Here is an example of calling the helper function.
<input type="checkbox" name="items" value="1" @Helpers.CheckedToggle("items", "1") />
And here is the checkedToggle helper which toggles the checkboxes.
@helper CheckedToggle(string option, string value)
if (HttpContext.Current.Request[option] != null)
var values = HttpContext.Current.Request[option].Split(',');
I’m not sure if the code will fit other situations as mine but maybe it will help someone else looking for a toggle routine to handle checkboxes.