I want to be able to save the checked state of several input checkboxes in cookies, so that I can read those
cookies to alter the state of a page (disable/invisiblize whichever tab pages the user deselected by unchecking
the corresponding check box).
I can *set* the checkboxes to either checked or unchecked based on boolean variables values, and I can *read* the cookies easily enough, but setting/writing the *cookie values* has been beyond me so far. I have Razor code like this:
@{
if (IsPost) {
Response.Cookies["someCookieVal"] = // how do I access the checked state of the checkbox here?
{
}
If this is not possible, or requires the sacrificing of chickens to accomplish, what is another way to save this cat's skin?
Member
18 Points
123 Posts
How can I access html elements in the IsPost section of the razor code?
May 29, 2013 05:33 PM|bclayshannon|LINK
I want to be able to save the checked state of several input checkboxes in cookies, so that I can read those
cookies to alter the state of a page (disable/invisiblize whichever tab pages the user deselected by unchecking
the corresponding check box).
I can *set* the checkboxes to either checked or unchecked based on boolean variables values, and I can *read* the cookies easily enough, but setting/writing the *cookie values* has been beyond me so far. I have Razor code like this:
If this is not possible, or requires the sacrificing of chickens to accomplish, what is another way to save this cat's skin?
HttpPost JQuery RAZOR HTML IsPost
All-Star
194009 Points
28028 Posts
Moderator
Re: How can I access html elements in the IsPost section of the razor code?
May 30, 2013 12:52 AM|Mikesdotnetting|LINK
A checkbox appears in the Request.Form collection only if it is checked. Otherwise it won't exist. So you can do this: