html - Textbox readonly property makes whole group readonly during implementation of datatime picker
问题描述
I am trying implement bootstrap datetime picket in my asp.net application. I have written the following code to display the datetime picker.
<div class="input-group date" data-provide="datetimepicker1">
<asp:TextBox ID="txtDateTime" runat="server" class="form-control" placeholder="Date Time" ReadOnly="true"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
<span>
<i class="glyphicon glyphicon-remove"></i>
</span>
</span>
</div>
I want to make the textbox, i.e., #txtDateTime
readonly because I want to avoid validation regarding date and time. But when I make readonly property "True", everything becomes read only including the <span>
that contain glyphicon glyphicon-calendar
. How can I make only the textbox
readonly.
Thanks Partha
解决方案
不确定您在只读跨度中的意思,无论如何您可以覆盖onkeydown
输入控件上的事件,这将是一个安全的解决方案,与您的解决方案一样与服务器端控件无关。
<input onkeydown="return false" />
在你的例子中试试这个:
<asp:TextBox ID="txtDateTime" runat="server" class="form-control" placeholder="Date Time" onkeydown="return false"></asp:TextBox>
推荐阅读
- c# - 如何在一组对象中查找特定值?
- email - 从 localhost 使用 Spring Boot 发送电子邮件
- database - 寻找数据集:关于新闻文章的元数据,跨越 15 年以上
- c# - 时间:2019-05-10 标签:c#webbrowsergoogle翻译点击听按钮
- c# - 如何在 C# 中缺少隐藏依赖项的构建失败?
- machine-learning - 机器学习中使用交叉熵的条件是什么
- python - 是否可以使用 python 2.7 将冒号(':')设置为配置文件中的分隔符?
- java - 如何根据之前选择的微调器更改其他微调器?
- java - Android DatePicker 禁用所有日期
- android - 带有 Room 的 Android 数据库不会触发回调