我知道这个问题以前有人问过,但我尝试过的所有解决方案似乎都不起作用。这可能是因为我对Java脚本的实际功能缺乏了解。经过几个小时的网络搜索和观看youtube视频,我还没有想出解决方案。我可以让java脚本在母版页上正常运行,但是当我将文本框和按钮放在更新面板中时,它会一直工作,直到触发单击事件,然后它会删除脚本。下面的任何指导都是我的代码的两个版本,它们都给了我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>