回发后页面中的值 [英] Values from page after postback

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

问题描述

我将(工作中的)Web应用程序从VS2003(.NET 1.1)转换为VS2008(.NET 3.5,ASP.NET 2.0),遇到了下一个问题:在客户端更改的文本框文本,到达时无需更改服务器端.该文本框位于用户控件中.

当查看Request.Form[...] 时,我看到的是正确的(更改的)文本,但是当查看控件本身时,它并未更改.

有任何想法吗?与ViewState/回发有何不同?

I converted my (working) web application from VS2003 (.NET 1.1) to VS2008(.NET 3.5, ASP.NET 2.0) and I''m experiencing the next problem: the textbox text which was changed on the client side, arrives without changes to the server side. The textbox is located in a user control.

When looking into Request.Form[...] I see the right (changed) text, but when looking into control itself it is not changed.

Any ideas? Any differences with ViewState / Postback?

How come there is a difference between Request.Form[..] and the control itself on the server side?

推荐答案

您是否已在服务器端禁用控件. .??
表示您提到

textbox.Enabled = false;

或制成ReadOnly 表示

textbox.ReadOnly = true;

??

每当从服务器端将控件设置为只读或禁用时,ASP.NET都不会对视图状态进行任何更改.

所以用

textbox.Attributes.Add("readonly", "readonly");

我认为这可能是原因. :rose:
Have you disabled the control in the server side .. .??
Means you mentioned

textbox.Enabled = false;

Or made ReadOnly means

textbox.ReadOnly = true;

??

ASP.NET do not make any changes to the viewstate whenever a control is set Readonly or Disabled from the server side.

So use

textbox.Attributes.Add("readonly", "readonly");

I think this might be the reason. :rose:


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

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