禁用文本框的损失视图状态 [英] Disabled textbox losses viewstate

查看:161
本文介绍了禁用文本框的损失视图状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是动态的基础上产生向下选择的放置形式。 该表单包含字段(十进制值+少量文本字段的数据输入)的。要在末尾添加所有的十进制值,并更新总文本框与价值。总文本框被禁用。

I am dynamically generating the form based on the drop down selected. The form consists of fields (data entry for decimal values + few text fields). Have to add all the decimal values at the end and update the Total TextBox with that value. Total Textbox is disabled.

当我点击窗体上的保存按钮后,用户输入他们的价值观,整个形式坚持在ViewState中除了禁用文本框。当启用文本框,一切工作正常。你要知道,我是动态生成的形式和使用JavaScript来计算(将所有十进制字段)更新总文本框的值。

When I click Save button on the form after the user have entered their values, whole form is persisted in viewstate except the disabled textbox. When I enable the textbox, everything works fine. Mind you, I am dynamically generating the form and updating the value of the total textbox using javascript to calculate (adding all decimal fields).

P.S。我做的一切权利为持续的视图状态。

P.S. I am doing everything right for persisting the viewstate.

那么是什么使能/禁止得到了轴承的视图状态

So what has the enabled/disabled got bearing on the viewstate

推荐答案

基本上,我添加了两个语句来得到它的工作。

Basically, I added two statements to get it working.

txtBox.Attributes.Add("readonly", "readonly");
txtBox.Style.Add("color","gray");

当我用txtBox.Enabled =假的,它没有坚持视图状态但没有它交替使用上述在我的code-隐藏页面的两个语句

When I used txtBox.Enabled = false, it didn't persist viewstate but did it alternatively using above two statements in my code-behind page

这篇关于禁用文本框的损失视图状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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