对于任何可以提供帮助的人,我都将jqwidget dateTimeInput日历合并到了Webforms页面上,由于某种原因,该页面未加载基于page_Load函数的代码。它应该将txtStartDate和txtEndDate默认为我用Date静态函数调用的值。如果有人能告诉我我想念的东西,这会有所帮助。我已经调试了后面的代码,并且一切都按我想要的方式工作,但是一旦加载,它就不会呈现在页面上。
服务器页面:
<script type="text/javascript">
$(document).ready(function () {
// Create a jqxDateTimeInput
$("#txtStartDate").jqxDateTimeInput({ width: '105px', height: '38px', template: "success", formatString: 'd' });
$("#txtEndDate").jqxDateTimeInput({ width: '105px', height: '38px', template: "success", formatString: 'd' });
});
</script>
<label style="vertical-align:bottom;">From</label>
<div id='txtStartDate'>
</div>
<label style="vertical-align:bottom;">To</label>
<div id='txtEndDate'>
</div>
<asp:CompareValidator id="valCompare" runat="server" ControlToValidate="txtStartDate" ControlToCompare="txtEndDate" Operator="LessThanEqual" Type="Date" ErrorMessage="End Date Must Be Later Than Start Date" Display="dynamic"></asp:CompareValidator>
<asp:RangeValidator id="valRange" runat="server" ControlToValidate="txtStartDate" Type="Date" ErrorMessage="Search Must Be One Week From Today To Six Months From Today" Display="dynamic">
</asp:RangeValidator>
<asp:RangeValidator id="valRange2" runat="server" ControlToValidate="txtEndDate" Type="Date" ErrorMessage="Search Must Be One Week From Today To Six Months From Today" Display="dynamic">
</asp:RangeValidator>
受保护的void Page_Load(对象发送者,EventArgs e) {
if (!IsPostBack)
{
txtStartDate.Text = DateTime.Today.AddDays(1).ToShortDateString();
txtEndDate.Text = DateTime.Today.AddDays(90).ToShortDateString();
valRange.MinimumValue = DateTime.Today.AddDays(7).ToShortDateString();
valRange.MaximumValue = DateTime.Today.AddMonths(12).ToShortDateString();
valRange2.MinimumValue = DateTime.Today.AddDays(8).ToShortDateString();
valRange2.MaximumValue = DateTime.Today.AddMonths(12).ToShortDateString();
//String startingDate = DateTime.Today.AddDays(7).ToString("MM/dd/yyyy");
//String endingDate = DateTime.Today.AddDays(90).ToString("MM/dd/yyyy");
}
}
public string StripString(string targetString)
{
return Regex.Replace(targetString, @"\W*", "");
}
public void SubmitButton_ServerClick(object sender, System.EventArgs e)
{
// if((SearchBox.Text != null) && (SearchBox.Text != ""))
//Server.Transfer("Events.aspx" + "?ticketResults=1&searchString=" + SearchBox.Text + "&parentid=" + CategoryList.SelectedValue + "&state=" + State.SelectedValue);
valRange.Validate();
valRange2.Validate();
valCompare.Validate();
if (valRange.IsValid && valCompare.IsValid && valRange2.IsValid)
{
string[] SearchStrings = SearchBox.Text.Split(' ');
string SearchString = "";
foreach (string foo in SearchStrings)
{
SearchString += StripString(foo) + " ";
}
//string SearchString = StripString(SearchBox.Text);
Response.Redirect(Request.FilePath + "?ticketResults=1&searchString=" + SearchString.Trim() + "&parentid=" + CategoryList.SelectedValue + "&state=" + State.SelectedValue + "&startDate=" + txtStartDate.Text + "&endDate=" + txtEndDate.Text);
}
//else if ((SearchBox.Text == null) || (SearchBox.Text == ""))
// Server.Transfer(Request.FilePath + "?parentid=" + CategoryList.SelectedValue + "&state=" + State.SelectedValue);
}