在按钮单击后放在更新面板内的body标签中不起作用

时间:2015-02-16 08:58:55

标签: jquery timepicker

最初在页面加载后,当我单击定时器控件文本框时,会弹出时间,但单击更新面板内的保存按钮后,Timer控件无法正常工作。请帮助..

在aspx页面中:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Timepicki is a light weight jQuery Time Picker plugin for using in form submission websites.">
    <meta name="keywords" content="timepicki, timepicker, time, jquery, plugins">

    <title>Workings</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <!-- Bootstrap core CSS -->
    <link href="css/timepicker/bootstrap.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="css/timepicker/style.css" rel="stylesheet">
    <link href="css/timepicker/timepicki.css" rel="stylesheet">
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="script1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="upd" runat="server">
            <ContentTemplate>
                <table border="1">
                    <tr>
                        <td colspan="2">
                            <input id="timepicker1" type="text" style="width: 80px" runat="server" name="timepicker1" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>
                                Enter Text</label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtText" runat="server" TextMode="MultiLine">
                            </asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnSave" CssClass="btn-success" runat="server" Text="Save" OnClick="btnSave_Click" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <!-- For Timepicker -->
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->

    <script src="js/timepicker/jquery.min.js"></script>
    <script src="js/timepicker/timepicki.js"></script>

    <script>
        $('#timepicker1').timepicki();
    </script>

    <script src="js/timepicker/bootstrap.min.js"></script>

    <!-- End For Timepicker -->    
    </form>
</body>
</html>

在后面的代码中:用于在表中插入值

    protected void btnSave_Click(object sender, EventArgs e)
    {

            string strID = "";

            if (txtText.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Msg", "<script language='javascript'>alert('Remarks cannot be empty!')</script>", false);
                return;
            }

            strID = objD.GetSequence("T_TEST", "TEST", "TID");

            objD.sQry = "";
            objD.sQry += "INSERT INTO T_TEST(TID,TDESC,CRE_DATE,CRE_USER,STATUS) VALUES('" + strID + "','" + txtText.Text.Trim().Replace("'", "''").ToString() + "',SYSDATE,'TEST USER','L')";
            int iAdd = objD.InsertSQL();

            //btnSendAuth.Enabled = true;
            Response.Redirect("Default.aspx?qVal=" + strID);
        }

    }

1 个答案:

答案 0 :(得分:0)

第一个问题是你在加载Bootstrap之前调用了timepicker。 第二个问题是你在呈现DOM之前运行它。 第三个问题是你有一个拼写错误,它应该是timepicker,而不是timepicki

这应该有效:

         

<script src="js/timepicker/jquery.min.js"></script>
<script src="js/timepicker/timepicki.js"></script>
<script src="js/timepicker/bootstrap.min.js"></script>


<script>
    $(document).ready(function(){
        $('#timepicker1').timepicker();
    });
</script>


<!-- End For Timepicker -->