简体   繁体   中英

Grab DateTime variable from CodeBehind to javascript in ASPX

I currently have a variable called ClassStartDate , so this variable is a DateTime . I want to grab this value and pass it to jquery datepicker to set min date. Is there a way to do it? I tried but I can't.

Here's what I've tried

ASPX.CS

public DateTime courseStartDate;

foreach (DataRow row in retrieveBAL.retrieveBatchByProjCode(ddlProjCode.SelectedValue).Tables[0].Rows)
{
       courseStartDate = Convert.ToDateTime(row["courseStartDate"]);
}

ASPX

$('#<%= tbStartDate.ClientID %>').datepicker({
                    dateFormat: 'dd-MM-yy',
                    changeMonth: true,
                    minDate: '<%= courseStartDate %>'
});
$('#<%= tbStartDate.ClientID %>').datepicker({
                        dateFormat: 'dd-MM-yy',
                        changeMonth: true,
                        minDate: '<%= courseStartDate.ToString("dd-MM-yy") %>'
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM