簡體   English   中英

如何使用jQuery在Asp.Net中使用DatePicker控件

[英]How to use a DatePicker control in Asp.Net using jQuery

當文本框聚焦時,我想彈出一個日歷控件。 一切工作正常,但未顯示日歷控件。

編碼:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="https://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $('#txt_date').datepicker();
            })
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:TextBox ID="txt_date" Class="txt_date" runat="server"></asp:TextBox>
            </div>
        </form>
    </body>
</html>

您還需要包含JqueryUI

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script> <--This is path to jqueryUI
  $( function() {
    $( "#txt_date" ).datepicker();
  } );
  </script>
 </head>
<body>


<form id="form1" runat="server">
<div>
    <asp:TextBox ID="txt_date" Class="txt_date" runat="server"></asp:TextBox>
</div>
</form>

 </body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM