网页上的控件不应失去其价值 [英] Controls on Web Page should not lose their value

查看:87
本文介绍了网页上的控件不应失去其价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,
我在Web窗体上有一些日期,TextBox,Dropdownlist控件.
Dropdownlist的AutoPostBack属性设置为True,通过该方法,只要我在该表单中填写所有其他文本框和日期详细信息,控件就不会保留其输入的值,并且会刷新,因此我必须再次输入详细信息,
这让它非常不安!!!!

请回复!!!!

问候,
aamir

Dear Friends,
i have some date,TextBox,Dropdownlist controls on web Form.
Dropdownlist is having AutoPostBack property to True, by which whenever i fill all other Textbox and date details in that Form the controls do not retain their enterd Values and gets Refreshed by which i have to again Enter the Details,
which makes it very uneasy!!!!

Pl reply!!!!

Regards,
aamir

推荐答案

您需要在页面中实现会话.
ASP.NET状态管理概述 [
You need to implement sessions in your page.
ASP.NET State Management Overview[^] should help you get started.


Dropdownlist的AutoPostBack属性设置为True,通过该方法,只要我在该表单中填写所有其他文本框和日期详细信息,控件就不会保留其输入的值,并且会刷新,因此我必须再次输入详细信息,
此特定行为由ASP.NET中的"Viewstate"控制.听起来好像已为您的应用程序禁用了它.

看这里:
MSDN:了解ASP.NET视图状态 [ MSDN:ASP.NET视图状态概述 [
Dropdownlist is having AutoPostBack property to True, by which whenever i fill all other Textbox and date details in that Form the controls do not retain their enterd Values and gets Refreshed by which i have to again Enter the Details,
This particular behaviour is controlled by ''Viewstate'' in ASP.NET. It sounds like it is disabled for your application.

Look here:
MSDN: Understanding ASP.NET View State[^]
MSDN: ASP.NET View State Overview[^]

Set it to true for the page. In page directive, set EnableViewState="true"




快速修复:
如果您仅遇到一次向下拖动回发的问题,则可以将控件放在 UpdatePanel 中,并添加一个触发器.这样,您将不会丢失其他数据,并且页面也不会闪烁.

希望这对您有帮助,

谢谢
-Amit
Hi,

A Quick Fix:
if you have issue with only one drowdown postback then you can place your control in UpdatePanel and add a trigger. this way you will not loose your other data and your page will not blink anymore.

hope this may help you,

thanks
-Amit


这篇关于网页上的控件不应失去其价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆