How to remove Up Down arrow keys from asp:textbox texmode:date?

让人想犯罪 __ 提交于 2020-01-17 04:27:10

问题


How to remove Up Down arrow keys from asp:textbox texmode:date? I have textbox with textmode date and I just want the calender arrow ?? how can I achieve this? in picture how can I disable the marked area controls??

<asp:TextBox Width="95%" ID="tourEndDate" runat="server" TextMode="Date"  onkeypress="return false" onKeyDown="return false"></asp:TextBox></td>

回答1:


Just use this:

  <Style>
    input[type=date]::-webkit-inner-spin-button {
        -webkit-appearance: none;
         display: none;
         }
    </style>

Or you can use datepicker. Just

Download AjaxControlToolkit.dll from web, add it to bin folder, then Add reference and then add

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 

to your aspx page. Style Part

<style type="text/css">
.cal_Theme1 .ajax__calendar_container   {
background-color: #DEF1F4;
border:solid 1px #77D5F7;
}

.cal_Theme1 .ajax__calendar_header  {
background-color: #ffffff;
margin-bottom: 4px;
}

.cal_Theme1 .ajax__calendar_title,
.cal_Theme1 .ajax__calendar_next,
.cal_Theme1 .ajax__calendar_prev    {
color: #004080;
padding-top: 3px;
}

.cal_Theme1 .ajax__calendar_body    {
background-color: #ffffff;
border: solid 1px #77D5F7;
}

.cal_Theme1 .ajax__calendar_dayname {
text-align:center;
font-weight:bold;
margin-bottom: 4px;
margin-top: 2px;
color: #004080;
}
</style>

Your TextBox

<asp:TextBox ID="txtDate" runat="server" AutoComplete="off"></asp:TextBox>
<cc1:CalendarExtender ID="ceFromDate" CssClass= " cal_Theme1" TargetControlID="txtDate" Format="dd-MMM-yyyy" runat="server"/>

It will appear like this.



来源:https://stackoverflow.com/questions/31157892/how-to-remove-up-down-arrow-keys-from-asptextbox-texmodedate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!