开发者

ASP.NET AJAX Control Toolkit CalendarExtender Date Change

I have a text box which I have extended with the AJAX Control Toolkit CalendarExtender. When I click on the text box, a calendar appears and I can select a date which then is added to the text box. So far so good.

This text box is used on a Grid View to filter the results in it. This was setup when I added a data source to the grid view.

This works fine other than the fact that after se开发者_Python百科lecting the date in the date control, I then also have to hit enter in the text box for the grid view to update. Can I get to update as soon as the date is selected rather than having to press enter?


This is because the TextBox_TextChanged event is not being raised. This can only be raised when focus is taken off the textbox, and since focus was put on it, the text has changed.

One option would be to use jQuery to force a postback whenever text is changed in the textbox.

Something like:

$("input.textbox").change(function(){
    __doPostBack();
});

This article may be of use for forcing Post Back from javascript:

http://weblogs.asp.net/yousefjadallah/archive/2010/06/27/insure-that-dopostback-function-implemented-on-the-page.aspx


If you want to refresh your grid without pressing the Enter key, put your textbox's autopostback property to true.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜