我有 2 个文本框控件,在页面加载时使用 j-query 预填充了一些默认日期。因此,当页面加载时,我的 GridView 应该根据这两个文本框控件中的日期加载一些数据。但问题是 GridView 没有在页面加载时加载任何数据,但是只有在我单击填充 gridview 的 Generate Report 按钮后才加载 gridview 。我试图调用从页面加载填充网格视图的函数,但它没有帮助。所以我发现这段代码触发了按钮单击事件,它似乎正在工作,但问题是它一直在循环......请帮助我接受任何建议。谢谢 这是触发 btnClick 事件的 j-query 但它一直在循环..
<script type="text/javascript">
$(document).ready(function(){
//this calls the btnClick event but it is looping..
$("[id*='btnClick']").click();
});
</script>
这是我在页面上的其他代码
<%@ Page Title="My Metrics" ClientIDMode="Static" Language="C#" MasterPageFile="~/Site.master" MaintainScrollPositionOnPostback="true" AutoEventWireup="true"
CodeFile="Summary.aspx.cs" Inherits="About" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<link href="Styles/ui-lightness/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.ui.datepicker.js" type="text/javascript"></script>
//here is the jquery that populates my textbox controls
<script type="text/javascript">
$(document).ready(function () {
$("#txtStartClosingDate").datepicker();
$("#txtEndClosingDate").datepicker();
var startdate = new Date();
startdate.setMonth(startdate.getMonth() - 1, 1);
$("#txtStartClosingDate").datepicker("setDate", startdate);
var endDate = new Date(); // current date
endDate.setDate(1); // going to 1st of the month
endDate.setHours(-1);
$("#txtEndClosingDate").datepicker("setDate", endDate);
});
</script>