Wednesday, March 21, 2012

CalendarExtender to fill 2 date text boxes

Anybody know of a way for a single CalendarExtender to fill 2 text boxes?

I would like a single calendar to fill both a start and end date. Because the TargetControlID only takes one parameter, I'm not sure how to do this.

Spent some time on google trying to find a solution but came up empty.

Thank you.

I came up with this simple solution.

In Page_Load

If Page.IsPostBack =FalseThen

Me.txtStartDate.Attributes.Add("onchange","FillEndDate()")

End if

<scripttype="text/javascript"language="javascript">

function FillEndDate(){

document.aspnetForm.ctl00_ContentPlaceHolder1_txtEndDate.value = document.aspnetForm.ctl00_ContentPlaceHolder1_txtStartDate.value

}

</script>

No comments:

Post a Comment