I need to use viewstate to persist a counter on a page during postbacks (im working on a form of an alternating content control so I need to track the last item viewed in order to know which one to display next time around).
Its 4.7.1, so its webforms, therefore I think it should be available, however I cannot figure our how to access it as from my cshtml, I dont have any current page context/reference.
I can use session state (through the current HTTP Context), but I dont really want to! :P
Ah I wouldn't worry, I did the same thing! I think the natural inclination is to try and use razor to do everything when the reality is, it's only supposed to add a touch of functionality instead of doing any heavy duty stuff... leave that to the user controls :-)
How about using a cookie to store the value? No problem reading and writing from your CSHTML via the Response.Cookies (to write) and the Request.Cookies (to read) collections.
I like the way how razor helps me to leave beind the old ASP.Net server control model and go back to good ol' HTTP. Also this will be good grounding if you intend to get on the MVC bandwagon for Umbraco v5.
I was thinking I could perhaps use an "<input type="hidden" ..." which is what viewstate is anyway! A cookie would work also - but am thinking that the correct route is not razor for this particular problem.
Viewstate - Can I access use this with Razor?
I need to use viewstate to persist a counter on a page during postbacks (im working on a form of an alternating content control so I need to track the last item viewed in order to know which one to display next time around).
Its 4.7.1, so its webforms, therefore I think it should be available, however I cannot figure our how to access it as from my cshtml, I dont have any current page context/reference.
I can use session state (through the current HTTP Context), but I dont really want to! :P
Can anyone help?
Adam
I wouldn't have thought you'd want to be doing this through razor (I'm not sure it's intended for this?). Maybe you should use a .NET user control?
Thats a fair point! This is my first project using razor - Im probably being blinded by the new stuff!
Ah I wouldn't worry, I did the same thing! I think the natural inclination is to try and use razor to do everything when the reality is, it's only supposed to add a touch of functionality instead of doing any heavy duty stuff... leave that to the user controls :-)
How about using a cookie to store the value? No problem reading and writing from your CSHTML via the Response.Cookies (to write) and the Request.Cookies (to read) collections.
I like the way how razor helps me to leave beind the old ASP.Net server control model and go back to good ol' HTTP. Also this will be good grounding if you intend to get on the MVC bandwagon for Umbraco v5.
I was thinking I could perhaps use an "<input type="hidden" ..." which is what viewstate is anyway! A cookie would work also - but am thinking that the correct route is not razor for this particular problem.
is working on a reply...