TextBox ReadOnly属性使整个组在实现Datatime Picker的实现过程中



我正在尝试在我的ASP.NET应用程序中实现Bootstrap DateTime纠察队。我编写了以下代码以显示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> 

我想制作文本框,即 #txtDateTime readonly,因为我想避免有关日期和时间的验证。但是,当我将阅读属性" true"制作时,所有内容都将仅读取,其中包括包含glyphicon glyphicon-calendar<span>。我如何只能读取textbox

谢谢partha

不确定您在读取跨度中的含义,无论如何您可以在输入控件上覆盖onkeydown事件,这将是一个安全的解决方案,这将是与服务器端控件(如您的解决方案)无关的解决方案。

<input onkeydown="return false"  />

在您的示例中尝试以下方法:

<asp:TextBox ID="txtDateTime" runat="server" class="form-control" placeholder="Date Time" onkeydown="return false"></asp:TextBox>

最新更新