Maintain viewstate for html elements?

综合技术 2018-05-18

I have a generic 'form page' user control that we use that allows editors to insert whatever kind of html form they want to inside of it, and it handles all of the form posts.

My question is, is there a way to store the vanilla non-asp form entries in the viewstate or otherwise save the entries on a form post, in the case that some server-side validation fails, so they can be restored when the page refreshes?

We currently already do upfront javascript validation that catches the majority of the input errors. We store all the form post data in a db before we do further processing, and some of the entries contain junk (spam we wish to ignore) or only partial info (i'm assuming those are cases where the user doesn't have javascript enabled). I'm trying to catch these last fringe cases so we do not process them.

If I am understanding this correctly, 1>User fills form 2>Clicks submit 3>Error detected on the server side 4>The Html posted back should contain the form i already filled with an error message on top.

Have you considered using JQuery Ajax?

The jquery ajax will post to a web method. The web method returns a JSON response. If the response is success redirect user to the next page, else show error on top of the page.

That way you don't need to maintain the state of the user input (since it is never lost).

Hello, buddy!

责编内容by:Hello, buddy! (源链)。感谢您的支持!

您可能感兴趣的

ios WKWebView 与 JS 交互实战技巧 最近公司需要针对 向日葵远程控制 和 花生壳动态域名解析服务客户端 做与HTML5交互的App,优点就是开发周期短,可随时更新内容。所以在这整理了一些 App 与 Web 交互的方法。 ...
块级元素行内元素以及display属性 1 、什 么叫做标签语义化 ? -> 合理的标签做合适的事 情 ->HTML 中常用的标签都有哪些 ? ( 块状标签和行内标签 ) ...
Tinder渐进式网页应用性能案例学习 Tinder最近对移动端“右滑”了。他们最近出品的响应式的 渐进式网页应用 —— Tinder Online ——已经可以在桌面和移动端使用了,应用采用了新技术做 JavaScript性能优化 ,并...
JavaScript Object Literals & amp; Arr... What is the difference between Object Literals and Array Literals in JavaScript? I know it has somet...
Javascript throws Uncaught TypeError: Un... I am debugging a 5-odd-year old script and this is driving me nuts. None of the answers I found c...