我知道之前曾有人问过这个问题,但是我尝试过的所有解决方案似乎都不起作用。可能是我缺乏有关Java脚本实际功能的知识。在经过数小时的网上搜索和观看youtube视频后,我无法提出解决方案。我可以使Java脚本即使在母版页中也能正常运行,但是当我将文本框和按钮放在更新面板中时,它会一直起作用,直到触发click事件,然后将其删除。任何指导都将在下面得到赞赏,因为我的代码的两个版本都给我daterangepicker错误不是函数:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master"
AutoEventWireup="true" CodeFile="datagrid.aspx.cs"
Inherits="DynamicDataGrid.datagrid" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<div style="padding-top: 10px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" OnClick="Button1_Click" Text="Search" Height="100%"/>
<asp:TextBox ID="txtFrom" runat="server"></asp:TextBox>
<asp:Label ID="From" runat="server" Text="Label" Visible="False"></asp:Label>
<asp:Label ID="To" runat="server" Text="Label" Visible="False"></asp:Label>
<asp:PlaceHolder id="PlaceHolder" runat="server"/></br></br>
<asp:Panel ID="Panel1" runat="server" CssClass="Avgsection">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"
Visible="False"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"
Visible="False"></asp:Label>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
<script type="text/javascript">Sys.Application.add_load(function(){
$(function () {
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val()
});
});
</script>
<script type="text/javascript">Sys.Application.add_load(function(){
$(function () {
$("#<%=txtFrom.ClientID %>").daterangepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
chandeDate: true
});
});
</script>
<script type="text/javascript">Sys.Application.add_load(function(){
$(function () {
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd"
}).val()
});
});
</script>
</asp:Content>
我也尝试过这个:
<script type="text/javascript">Sys.Application.add_load(function () {
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val()
});
</script>
<script type="text/javascript">Sys.Application.add_load(function(){
$(function () {
$("#<%=txtFrom.ClientID %>").daterangepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
chandeDate: true
});
</script>
<script type="text/javascript">Sys.Application.add_load(function(){
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val()
});
</script>