回发后字段为空 [英] After Postback the fields blank

查看:104
本文介绍了回发后字段为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个表单,其中包含两个下拉列表和一个ASP文本框,当
页面回发文本框中包含的数据已消失.

Hi,

I have a form which contains two dropdown list and one asp textbox, when the
page postback the data that contained in the textbox is disappeared.

Thanks!

推荐答案

页面回发,文本框中包含的数据消失了
听起来像控件/页面的视图状态已关闭.



您必须使用空白文本框的代码,而不能仅第一次使用IsPostback.
page postback the data that contained in the textbox is disappeared
Sounds like the viewstate of the control/page switched off.

OR

You must be using a code blank out the textboxes and not using IsPostback to do it only for the first time.


问题的答案很简单.没有runat="server"的所有内容在回发后将不会保留.如果您将runat ="server"放到服务器上,但希望客户端ID不变,请使用clientidmode="Static"并确保没有两个ID相同.

如果您设置了runat服务器属性,那么Sandeep的答案将说明原因.您可能被禁用了viewstate,或者将page_load中的文本框初始化为一个空字符串,而没有检查回发.

如果仍有问题,请进一步解释.
The answer to your question is very simple. Anything which don''t have runat="server" will not persist after postback. If you put runat="server", but want the client Id doesn''t change than use the clientidmode="Static" and make sure no two ids are same.

If you have runat server attribute set, then Sandeep''s answer explains why. You may be disabled viewstate or you initialize the textbox in the page_load to an empty string without a check for postback.

Explain more if you have still issues.


您好,请访问此链接

http://forums.devshed.com/net-development-87/how-do-i-keep-a-variables-value-during-postback-119008.html
hi visit this link

http://forums.devshed.com/net-development-87/how-do-i-keep-a-variables-value-during-postback-119008.html


这篇关于回发后字段为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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