Please find the my below code default.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
$(function () {
$("#<%= TxtFrm.ClientID %>").datepicker();
$("#<%= TxtTo.ClientID %>").datepicker();
$("#<%= TxtFrm.ClientID %>").on('change', function () {
var d = new Date();
var month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : '' + (d.getMonth() + 1);
var day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate();
var year = d.getFullYear();
var current_date = month + "/" + day + "/" + year;
var date = $("#<%= TxtFrm.ClientID %>").val();
if (new Date(current_date).getTime() < new Date(date).getTime()) {
$("#<%= TxtLev.ClientID %>").val("Planned");
} else {
$("#<%= TxtLev.ClientID %>").val("Unplanned");
}
});
});
<%--
$(function () {
$("[id*=TxtTo]").blur(function () {
var user = {};
user.FromDate = $("[id*=TxtFrm]").val();
user.ToDate = $("[id*=TxtTo]").val();
console.log(user.FromDate);
console.log(user.ToDate);
$.ajax({
type: "POST",
url: "Default.aspx/GetCustomers",
data: '{user: ' + JSON.stringify(user) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
console.log(r);
var ddlCustomers = $("[id*=ddlCustomers]");
ddlCustomers.empty().append('');
$.each(r.d, function () {
ddlCustomers.append($("").val(this['Value']).html(this['Text']));
});
},
error: function (data) {
alert("fail");
}
});
});
});
<----------default.cs-------------------->
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Services;
using System.Configuration;
using System.Data.SqlClient;
using System.Web.Script.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public class Name
{
public String FromDate { get; set; }
public String ToDate { get; set; }
}
[WebMethod]
[ScriptMethod]
public static List GetCustomers(Name user)
{
string constr = ConfigurationManager.ConnectionStrings["LMS"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("select Emp_Nm from dbo.Emp_Master"))
{
List customers = new List();
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@fromdate", user.FromDate);
cmd.Parameters.AddWithValue("@todate", user.ToDate);
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(new ListItem
{//Value = sdr["CustomerId"].ToString(),
Text = sdr["Emp_Nm"].ToString()
});
}
}
con.Close();
return customers;
}
}
}
}
Imran BagawanPosted May 14, 2016, 1:30 AM
Purba AnggaraPosted May 12, 2016, 1:40 AM
Purba AnggaraPosted May 12, 2016, 1:38 AM
Imran BagawanPosted May 12, 2016, 1:33 AM
Purba AnggaraPosted May 12, 2016, 1:22 AM
format Date Visit https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx