为什么一个只读文本框不ASP.NET中返回任何数据? [英] Why does a read-only textbox does not return any data in ASP.NET?

查看:104
本文介绍了为什么一个只读文本框不ASP.NET中返回任何数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置一个文本框为只读。当用户点击它,则显示一个日历和用户选择其输入到只读文本框的时间

I've set a textbox to read-only. When the user clicks on it, a calendar is displayed and the user selects the date which inputs into the read-only textbox.

但是,当我尝试将数据输入到数据库中,它显示空值。什么是错的?

But when I try to enter the data into the database, it shows null value. What is wrong?

推荐答案

有陌生感是一点点,当涉及到ASP.NET 只读属性和的HTML input元素的只读属性。而不是设置Web控件的只读属性尝试只需添加HTML属性,像这样的控件:

There is a little bit of strangeness when it comes to the ASP.NET Readonly property and the readonly attribute of an HTML input element. Rather than setting the Readonly property of the web control try simply adding the HTML attribute to the control like this:

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

这将使只读在客户端的浏览器中的控制,但仍允许您检索输入的值时,回发到服务器。

This will make the control read-only in the client's browser yet still allow you to retrieve the value of the input when it posts back to the server.

这篇关于为什么一个只读文本框不ASP.NET中返回任何数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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