【问题标题】:TIMEPICKER JQUERY DEMOTIMEPICKER JQUERY 演示
【发布时间】:2014-03-31 08:41:48
【问题描述】:

如何将日期计时器绑定到文本框

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Click-2-Call.aspx.cs" Inherits="Click_2_Call" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Click2Call</title>
    <script type="text/javascript" src="JS/jquery-ui.js"></script>
    <script type="text/javascript" src="JS/jquery-ui.min.js"></script>
    <script type="text/javascript" src="JS/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="JS/jquery-ui-timepicker-addon.js"></script>
    <style type="text/css">
        .numbers
        {
            width: 50px;
            text-align: center;
            font-family: Arial;
            font-size: 24px;
            font-weight: bold; /* options are normal, bold, bolder, lighter */
            font-style: normal; /* options are normal or italic */
            color: #3d3d3d; /* change color using the hexadecimal color codes for HTML */
        }
        .title
        {
            width: 50px;
            text-align: center;
            font-family: arial;
            font-size: 10px;
            font-weight: bold; /* options are normal, bold, bolder, lighter */
            color: #3d3d3d; /* change color using the hexadecimal color codes for HTML */
        }
        .numbers1
        {
            width: 50px;
            text-align: center;
            font-family: Arial;
            font-size: 22px;
            font-weight: bold; /* options are normal, bold, bolder, lighter */
            font-style: normal; /* options are normal or italic */
            color: #999; /* change color using the hexadecimal color codes for HTML */
        }
        .style2
        {
            height: 28px;
            border: 2px solid green;
        }
        .style19
        {
            width: 70px;
            height: 12px;
        }
        .style24
        {
            width: 70px;
            height: 32px;
        }
        .style37
        {
            width: 221px;
            height: 32px;
        }
        .style38
        {
            width: 221px;
            height: 12px;
        }
        .style42
        {
            width: 70px;
            height: 11px;
        }
        .style43
        {
            width: 221px;
            height: 11px;
        }
        .style47
        {
            height: 10px;
        }
        .style48
        {
            width: 221px;
            height: 10px;
        }
        .Border
        {
            width: 313px;
            margin-top: 0px;
            height: 320px;
            margin-right: 14px;
            border: 2px solid green;
            background: url(Image/backgroundimage1.jpg) no-repeat;
            background-size: 440px;
        }

        .style49
        {
            height: 10px;
            width: 70px;
        }
    </style>

</head>
<body onload="countdown(yr, m, d, hr, min)">
    <form id="form1" runat="server">
    <div class="Border">
        <table style="width: 313px; margin-top: 0px; height: 320px; margin-right: 14px;">
            <tr>
                <td class="style2" colspan="2">
                    <asp:Label ID="lblClick2Call" runat="server" Text="Click2Call" Font-Bold="True" Font-Size="Larger"></asp:Label>
                    <img alt="Imga" src="Image/smart.jpg" width="25px" height="25px" style="float: right" />
                </td>
            </tr>
            <tr>
                <td class="style24">
                    &nbsp;
                    <asp:Label ID="lblName" runat="server" Text="Name :" Font-Names="Tahoma" Font-Bold="True"
                        Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style37">
                    <asp:TextBox ID="txtName" runat="server" Height="22px" Width="205px" MaxLength="500"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style19">
                    &nbsp;
                    <asp:Label ID="lblNumber" runat="server" Text="Number :" Font-Names="Tahoma" Font-Bold="True"
                        Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style38">
                    <asp:TextBox ID="txtNumber" runat="server" Height="22px" Width="205px" MaxLength="500"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvNumber" runat="server" ControlToValidate="txtNumber"
                        ErrorMessage="*" ToolTip="Please Enter the Number" ValidationGroup="vgCallMe"
                        ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    <asp:CustomValidator ID="cvNumber" runat="server" ControlToValidate="txtNumber" OnServerValidate="TextValidate"
                        ErrorMessage="*" ToolTip="Please Enter Only Digit or Numberic value or Atleast 10 digit"
                        ValidationGroup="vgCallMe" ForeColor="Red" SetFocusOnError="True"></asp:CustomValidator>
                </td>
            </tr>
            <tr>
                <td class="style19">
                    &nbsp;
                    <asp:Label ID="lblEmail" runat="server" Text="Email :" Font-Names="Tahoma" Font-Bold="True"
                        Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style38">
                    <asp:TextBox ID="txtEmail" runat="server" Height="22px" Width="205px" MaxLength="500"></asp:TextBox>
                    <asp:CustomValidator ID="cvEmail" runat="server" ControlToValidate="txtEmail" OnServerValidate="EmailValidate"
                        ErrorMessage="*" ToolTip="Please Enter Valid Email Id..." ValidationGroup="vgCallMe"
                        ForeColor="Red" SetFocusOnError="True"></asp:CustomValidator>
                </td>
            </tr>
            <tr>
                <td class="style19">
                    &nbsp;
                    <asp:Label ID="lblLocation" runat="server" Text="Location :" Font-Names="Tahoma"
                        Font-Bold="True" Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style38">
                    <asp:TextBox ID="txtLocation" runat="server" Height="22px" Width="205px" MaxLength="500"
                        Font-Names="Tahoma"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style19">
                    &nbsp;
                    <asp:Label ID="lblLanguage" runat="server" Text="Language :" Font-Names="Tahoma"
                        Font-Bold="True" Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style38">
                    <asp:DropDownList ID="ddlLanguage" runat="server" Height="23px" Width="207px" AutoPostBack="false"
                        Font-Names="Tahoma" Font-Size="8.25pt">
                        <asp:ListItem Selected="True" Value="1">English</asp:ListItem>
                        <asp:ListItem Value="2">Hindi</asp:ListItem>
                        <asp:ListItem Value="3">Marathi</asp:ListItem>
                        <asp:ListItem Value="4">Punjabi</asp:ListItem>
                        <asp:ListItem Value="5">Gujrati</asp:ListItem>
                        <asp:ListItem Value="6">Bengali</asp:ListItem>
                        <asp:ListItem Value="7">telgu</asp:ListItem>
                        <asp:ListItem Value="8">kanada</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style42">
                    &nbsp;
                    <asp:Label ID="lblTime" runat="server" Text="Time :" Font-Names="Tahoma" Font-Bold="True"
                        Font-Size="8.25pt"></asp:Label>
                </td>
                <td class="style43">
                    <asp:TextBox ID="txtTime" runat="server" Height="22px" Width="205px" MaxLength="500"
                        Font-Names="Tahoma"></asp:TextBox>

                </td>
            </tr>
            <tr`enter code here`>
                <td class="style49">
                </td>
                <td class="style48">
                    <asp:Button ID="btnCallMe" runat="server" Text="Call Me" Width="81px" ValidationGroup="vgCallMe"
                        OnClick="btnCallMe_Click" />
                    <asp:Button ID="btnClear" runat="server" Text="Clear" Width="90px" OnClick="btnClear_Click" />
                </td>
            </tr>
            <tr>
                <td class="style47" colspan="2">
                    <asp:Label ID="lblcopyRight" Text="©2014@SmartConnect Technologies Pvt. Ltd." runat="server"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
    <div style="width: 295px">
        <asp:Label ID="lblDisplayMessage" runat="server" Text="Label" Font-Bold="True" Visible="False"></asp:Label>
    </div>  
    </form>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#txtTime").datetimepicker();
            });        
    </script>
</body>
</html>

【问题讨论】:

  • 嗨,请帮助它不工作

标签: jquery


【解决方案1】:

给那个文本框一个类名。因为 id 在渲染时会发生变化,因为它具有属性runat=server

html

<asp:TextBox ID="txtTime" CssClass="txtTime" runat="server" Height="22px" Width="205px" MaxLength="500"
                    Font-Names="Tahoma"></asp:TextBox>

那么你可以使用like

 $(document).ready(function() {
        $(".txtTime").datetimepicker();
        });  

编辑

像这样改变脚本的顺序

<script type="text/javascript" src="JS/jquery-1.7.min.js"></script>
<script type="text/javascript" src="JS/jquery-ui.js"></script>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" type="text/css" />

因为 jquery.ui 需要 jquery。在您的情况下,执行 jquery.ui 时 jquery 不存在。这会出错。

【讨论】:

  • 但是为什么亲爱的你能给我解释一下
  • 嗨可以帮助我如何赋予风格
  • 脚本>
  • 嗨,添加后请帮助我
  • code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-05
  • 2013-07-06
相关资源
最近更新 更多