我在aspx方面有这个:
<asp:TextBox runat="server" ID="txtBoxStartTime" TextMode="Time"></asp:TextBox>
在vb.net方面,当我尝试从这个文本框中获取Text值时,我只有空字符串(“”).
CDate(txtBoxStartTime.Text)
在客户端,在webInspector中我可以轻松地从文本框中获取值,但我需要在服务器端…
即使我尝试使用runat =“server”的HTML5标签,我也会遇到同样的问题.
我注意到问题与Framework 4.5上的所有Textmode属性相同
对此有何建议/解决方案?
我非常感谢您的投入!
谢谢!
解决方法
SingleLine mode displays the TextBox control as a single row. If the
user enters text that exceeds the physical size of the TextBox
control,the text will scroll horizontally. MultiLine mode displays
the height of the TextBox based on the Rows property,and allows data
entry on multiple lines. The text will automatically wrap if the Wrap
property is set to true. If the user enters text that exceeds the
physical size of the TextBox,the text will scroll accordingly and
scroll bars will appear. The behavior of Password mode is similar to
SingleLine mode except that all characters entered in the TextBox
control are masked and are not saved in view state.
然后
The remaining options correspond to type attribute values for the
input element in the HTML5 specification.
因此,文本框的服务器端行为没有任何变化,以下代码按预期工作
<asp:TextBox runat="server" TextMode="Time" ID="test"></asp:TextBox> <asp:Button runat="server" ID="btn" Text="ok" />
C#代码落后
protected void Page_Load(object sender,EventArgs e) { string value = test.Text; }