我有一个像这样的 asp、net 文本框
<asp:TextBox readonly="true" ID="txtLastService" runat="server"></asp:TextBox>
当我尝试将其值获取到后面代码中的日期变量 LastService 时,出现此错误
Conversion from string "" to type 'Date' is not valid.
Exception Details: System.InvalidCastException: Conversion from string "" to type 'Date' is not valid. Source Error: Line 26: oItem.LastService = txtLastService.Text Source File: .\admin\vehicle\add.aspx.vb Line: 26
我在其他页面中使用了相同的代码,并且工作正常,除了这个页面 任何帮助
编辑
请注意,当我单击表单上的“提交”时,文本框的值不为空。而且当我删除只读属性时,我没有收到错误。但我需要这个文本框是只读的,因为我使用 JavaScript 来选择日期并设置其值
最佳答案
而不是 Readonly="true"
,尝试使用 Enabled="false"
关于asp.net - 无法获取asp.net中只读文本框的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10184392/