I would like to like to trigger a postback after user selects a date. Am using the AjaxControlToolkit's CalendarExtender control. The date textbox which is associated to the extender is editable too which enables the user to manually enter the date in a particular format. Values of quite a few controls which reside on that page are to be updated depending on the newly selected date and hence going to the server is a must.
I did try using the OnClientDateSelectionChanged property of the extender which lets me hook in my custom javascript, using which i was planning to trigger a postback but for some odd reason the function gets called only if the date is selected using an extender and not when manually edited (Hoping that it doesn't catch the click event over textbox's change).
Am sure many have tackled this issue before. Please do share. Thanks.
Here it is, Keep It Simple as they say. Set AutoPostBack of the text box to true and capture the OnTextChanged event on the server side.
Related
What events are triggered when a focus is set into TextBox?
And similarly what events are triggered when focus is set out from TextBox?
I have several TextBoxes in a FormView.
I have tabbed into a Textbox.
How can I write a generic code to find out the ID of this TextBox programatically (without using JavaScript)?
How can I get the text value from this TextBox?
You are asking 2 separate questions. For the first one - what events are triggered when focus is set in the browser (assuming in VB code) - the answer is none. A quick scan of the MSDN documentation for the control for exposed events here should confirm that. You would have to respond to focus changes on the browser via javascript in some manner.
For the second question, if you can live with responding when the page is posted back to the server rather than on focus change. You can assign all your textboxes to the same TextChanged event, and then the sender property will be the textbox which had the change. Connecting Multiple Events to a Single Event and/or AddHandler Statement
Hello guys i been using asp.net calendars for giving the user filtering options over a grid table.
Now i decided to try the ajax extender to save some room on the page.
The moment the user clicks on one of the calendars the grid updates/changes ( i got some code in the SelectionChanged of the calendars that after few rows gives 2 date values that are sent to the sql and used as the allowed date range for the filter/select command ).
Now my problem is that unlike the regular calendar the ajax extender got no postback and no selectionchanged event i can use code in , and i not so sure how to make it all work without those 2 options.
The calendar extender "extends" your control. You still use your control's events. The extender will basically "impersonate" a user typing text into the control...
Catch the events on the control that the extender is bound to, not the extender itself.
I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him.
I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.
Is there any way to do the same without reloading of the page in a easiest way possible without using ajax control toolkit?
Additional info: the data for the dropdownlist is coming from the database, and some places it has to be all server side so i can't use javascript .
You can try this idea: http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx. I have not try it before but it seems logical.
you should go through updatepanel. Put all the controls inside a updatepanel which you want to show on selectedindexchanged event of the dropdownlist and write code behind on selectedindexchanged event of the dropdownlist accordingly. Hope this will help you...
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?
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.
I have a custom server control (composite control having dynamically created dropdown boxes and textboxes). I have enabled AJAX in order to avoid page reload.The server control is used inside the ASP.NET webcontrol having few buttons which controls the visibility of the server control. Now I enter values in the dropdown box and texboxes and click on any other button. After this postback the last entered values are gone! The control is not remembering the values. Can anyone help me? How can I retain the values after post back?
Ensure that the controls are given the exact same ID after each postback. Also you might want to try initialising your dynamic controls (DropDownList and TextBox) during Page_Init if possible.
If your custom server control is create dynamically all the controls, then you need to recreate them on every post, and you need to create them before the Page_Load(), or else the asp.net cant know them to filled with the post data.
To solve this, if you can not create them before the Page_Load(), then you can fill them by your self with the posted data by using the Request.Form[YourCustomControl.UniqueID] for all controls.
You need to re-create on each postback, see This article