Selection change event does not fired (trigger)
User selects a date from the date-picker and the date is put into a text-box.
But when i choose a date some date should check another text box date an开发者_如何学Cd give me the difference. The selection-change event does not fire (as expected).
protected void dtpleavestartdate_SelectionChanged(object sender, EventArgs e)
{
string a = "NO CHANGE";
a = a + dtpenddate.SelectedDate.Subtract(dtpleavestartdate.SelectedDate).ToString();
Response.Write("<script>alert('" + a +"')</script>");
}
Which date-picker control are you using? From your code, it appears that your are using server side event handling - so whatever control that you are using must be providing server side event. Also, it should have some mode to indicate that post back to happen when selection is made (like AutoPostBack property in dropdown) - w/o post-back no server side event will happen.
I would also suggest you to consider client side logic (if possible) for your scenario.
You have to make sure :
In the property page click on event tab and check if in the event SelectionChanged is specify the event handler(in your case dtpleavestartdate_SelectionChanged)
check if the date that is posted after the page postback is different from the control default date(maybe the one you set on the page load if is not a page.postback) .if they are not different the event is not gonna be raised.
-check if the AutoPostBack Property is set to True
精彩评论