2017-10-20 97 views
0

I'm新使用的aspx項目,在前端我的表是這樣的:.aspx的日期選擇瀏覽器的兼容性

<table style="width: 450px" id="tabla1"> 
    <tr> 
    <th style="text-align:left"> 
     <asp:Label runat="server" ClientIDMode="Static" ID="label_fechaini" Text="Fecha de Apertura:" Width="50%"></asp:Label> 
     <br /> 
    </th> 
    <th style="text-align:left"> 
     <asp:Label runat="server" ClientIDMode="Static" ID="label_fechafin" Text="Fecha de Cierre:" Width="50%"></asp:Label> 
     <br /> 
    </th> 
    </tr> 
    <tr> 
    <td> 
     <asp:TextBox type="date" ClientIDMode="Static" runat="server" ID="fecha_ini"></asp:TextBox> 
    </td> 
    <td> 
     <asp:TextBox type="date" ClientIDMode="Static" runat="server" ID="fecha_fin"></asp:TextBox> 
    </td> 
    </tr> 
</table> 

的Chrome瀏覽器,我可以看到日期選取器沒有問題是這樣的:

enter image description here

問題是與其他瀏覽器兼容,例如IE不會顯示datepicker.I搜索CanIuse網絡。而IE不支持日期。我能做些什麼來解決這個問題?

IE圖片:

enter image description here

回答

1

我假設你沒有運行IE 7或任何東西真的老了。 我會考慮JQueryUI Datepicker。 它適用於最近的IE和Firefox/Chrome/Mozilla等。

$("#fecha_ini").datepicker(); 

您可能需要使用此參考輸入ID。

$("#<%= fecha_ini.ClientID %>").datepicker(); 

編輯

我的錯。我相信你不能將datepicker應用於asp:TextBox控件,並且它只能用於html輸入。我從答案中刪除了該部分。

您需要包含JQUERY和JQUERYUI才能完成此工作。

<script> 
    $(document).ready(function() 
    { 
     // Regular way to apply datepicker 
     $("#fecha_ini").datepicker(); 
     $("#fecha_fin").datepicker(); 

     // If you get error because it cannot find the control use this. 
     //$("#<%= fecha_ini.ClientID %>").datepicker(); 
     //$("#<%= fecha_fin.ClientID %>").datepicker(); 
    }); 
</script> 
<table style="width: 450px" id="tabla1"> 
    <tr> 
     <th style="text-align:left"> 
      <asp:Label runat="server" ClientIDMode="Static" ID="label_fechaini" Text="Fecha de Apertura:" Width="50%"></asp:Label> 
      <br /> 
     </th> 
     <th style="text-align:left"> 
      <asp:Label runat="server" ClientIDMode="Static" ID="label_fechafin" Text="Fecha de Cierre:" Width="50%"></asp:Label> 
      <br /> 
     </th> 
    </tr> 
    <tr> 
     <td> 
      <asp:TextBox type="date" ClientIDMode="Static" runat="server" ID="fecha_ini"></asp:TextBox> 
     </td> 
     <td> 
      <asp:TextBox type="date" ClientIDMode="Static" runat="server" ID="fecha_fin"></asp:TextBox> 
     </td> 
    </tr> 
</table> 
+0

代替該線'的'應該使用''? – Pepe

+0

@Pepe不,這個JavaScript將日期選擇器功能添加到現有的文本框中。它不是文本框本身的替代品。您仍然需要標記中的文本框聲明。 – mason

+0

我的文本框應該是什麼樣子。它需要'type = date'?或簡單的''? – Pepe