“节省”的最佳方式文本框中的值(ASP.NET)?
我有一个文本框,用户在其中输入一些数据并将该值保存到数据库中。下次用户在同一会话中访问同一 aspx 页面时,应在文本框中恢复该值。最好的方法是什么?也许使用会话?
谢谢 :-)
I have a textbox where the user enters some data and saves this value to the database. Next time the user comes to the same aspx page in the same session, the value should be restored in the textbox. Whats the best way to do this? Using the session maybe?
Thanks :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
会话是保存数据的好方法。如果会话不可用,您还应该有一种方法从数据库加载数据。 (即,他们第二天来到同一页面)
如下所示:
The session is a good way to save the data. You also should have a way to load the data from the database if the session is not available. (ie, they come to the same page the next day)
something like this:
使用会话,您只能在会话内执行此操作,除非您在状态服务器或数据库中维护会话。
第一次,将用户输入的文本存储到会话中,并在数据库中更新它。稍后,每当您需要向用户显示该值时,请检查该文本框值是否存在于会话中。如果没有,则从数据库中读取它,用该值更新会话并将其显示给用户。
Using the session, you will be able to do it only within a session unless you maintain a session in state server or in database.
For the first time, store the user entered text into the session and also update it in the Database. Later, whenever you need to show this value to the user, check whether the textbox value exits in the session. If not, then read it from the database, update the session with the value and show it to the user.