我有一个文本框,我使用 AJAX 控件工具包 CalendarExtender 对其进行了扩展。当我单击文本框时,会出现一个日历,我可以选择一个日期,然后将其添加到文本框中。到目前为止,一切都很好。
此文本框在网格视图上用于过滤其中的结果。这是我在网格视图中添加数据源时设置的。
除了在日期控件中选择日期后,我还必须在文本框中按 Enter 以使网格视图更新之外,这种方法工作得很好。我可以在选择日期后立即更新,而不必按 Enter 键吗?
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 selecting 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?
发布评论
评论(2)
这是因为
TextBox_TextChanged
事件没有被引发。仅当焦点离开文本框时才能引发此问题,并且由于焦点放在文本框上,因此文本已更改。一种选择是每当文本框中的文本发生更改时使用 jQuery 强制进行回发。
类似于:
本文可能用于强制从 javascript 回发:
http://weblogs.asp.net/yousefjadallah/archive/2010/06/27/insure-that-dopostback-function-implemented-on-the-page.aspx
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:
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
如果您想在不按 Enter 键的情况下刷新网格,
将文本框的
autopostback
属性设置为true
。希望这有帮助。
If you want to refresh your grid without pressing the Enter key,
put your textbox's
autopostback
property totrue
.Hope this helps.