如何在 asp.net 中查看正常 HTML 输入的状态
如何在 ASP.net 中的普通 HTML 输入元素中使用 VIEWSTATE。我有一个包含很多输入元素的表单,并且我有正常的(不是 asp.net 输入元素)输入元素。现在我应该维护这些元素的视图状态。
谢谢
How to use VIEWSTATE in normal HTML input elements in ASP.net. I am having a form with lot of input elements and i had normal(not asp.net input elements) input elements. Now i should i maintain viewstate for these elements.
Thank You
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试编写 JavaScript 函数,在回发之前将输入值存储在
asp:HiddenField
中并在回发后从中恢复值。
例子:
Try writing javascript function, that store input values in
asp:HiddenField
before postbackAnd restore values from it after postback.
Example:
普通html元素中还有一个“enableviewstate”属性,只需将其设置为true即可。
There is also a property of "enableviewstate" in normal html elements, just set it to true.
没有理由这样做,因为在回发之后,输入元素再次将值发送到页面,并在回发后再次拥有内容。
这样做的唯一原因是尝试在发布之前获取先前的值后退。
There is not reason to do that because after the post back the input elements post the value again to the page, and have the content again after the post back
The only reason to do that is to try to get the previous values, before the post back.
这篇文章发表已经有一段时间了,但这是我的解决方案,对我有用。
只需在 ASP.Net 中为 html 控件设置 runat="server" 属性,而不是隐藏字段。
例如,
这将做两件事:
It's been awhile since this post was made, but here's my solution which worked for me.
Instead of hidden fields, just set the runat="server" attribute for your html control in ASP.Net.
E.g.
This will do two things: