ASP.NET AJAX Control Toolkit CalendarExtender Date Change - asp.net

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.

Related

.Net textbox is null when a "submit" link is clicked

Good day,
I have a problem in a .NET page where I am using an asp:textbox in combination with an OnClick action on a link button.
What happens is that after text has been entered into the textbox, if you directly click on the link button, more often than not the textbox is considered to be null.
If you click off the text box first then click the link, all is well and the save function performed by the link button proceeds as expected.
My assumption is that there is a lifecycle event that is being missed, or not applied which is not binding the text to the textbox for use in the codebehind when the link button is clicked.
The question is, what can i do to enforce that binding short of doing something like adding an onkeypress event to the textbox to force a postback.
There must be a more elegant solution.
Thank you in advance for your help.
Do you have initializations on your textbox inside Page_Load event? If so, use IsPostBack=false and put the initialization inside.
If IsPostBack =False Then
TextBox1.text=""
End If

AutoPostBack using ASP.NET text box and AjaxControlToolkit CalendarExtender

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.

Get element text before page reloads in ASP.net web forms

I am unfortunately having to work with asp.net web forms. I have a label that has a different Text property every time the page loads. I have a button that is clicked. I have double clicked on the button and it has shown me a code view.
I get a reference to the label via labelID.Text, but it refers to the value of the text that is about to be displayed on the next page load. How would I get the text of the value when the button was actually clicked? Or is web forms not advanced enough for that.
Search where the labelID.Text is modified (maybe Page_Load event), and save the text before in a global variable.
It sounds like on every page load or postback, somewhere there is code which applies a new value to labelID.Text. Where is that work being done? Page_Load?
In any case, wherever that work is being done, you most likely have access to both the existing text value of the control, and the new text value you're about to give it.

AspxGridView: How to Disable PostBack When I Click on Button Inside of DataItemTemplate?

I have an AspxGridView and it has a Button inside of a column's DataItemTemplate.
When the value of this column is "0", the image of button is X, when it's "1", the image is a tick. Like yes/no.
So my system is working this way: I click on the button, there comes an edit form, when I edit it, I change the value from 0 to 1, then the image becomes tick. Like "edited/unedited".
I've placed the edit form inside of an AspxPopupControl, it works normal but slow. Because the grid has too many rows and the button causes postback before the popup appears. That's because I'm setting the PopupControl.ShowOnPageLoad to true.
I tried also javascript window.open function to avoid from this postback. But since it's a button, it makes postback anyway. If I disable postback from Button properties it has no action.
I used an imagebutton, or imagelink, but I also have to get the ID with Eval, couldn't figure how to do that.
So, I need to open an edit form, doesn't matter with popup control or new popup page, and I need to do this without postback. I can use a different control inside of DataItemTemplate, just need to get the key value of the row.
Any suggestions?
I recommend using the built-in popup EditForm template:
http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/PopupEditForm.aspx
Also, use the built in check box column type. These changes should give you better performance.
by using UpdatePanel
then GridView and event Load

How can I delay a ASP.NET AutoPostBack so JavaScript fires first?

I've got an odd situation with a text box and an autocomplete setup on my page. I'm using a JQuery based autocomplete on a text box that has AutoPostBack="True". This works perfect if I use the keyboard to select an autocomplete item, which then fires Jquery to fill in the text box, and then when I tab out of the box the AutoPostBack fires. If, however, I click on an autocomplete item, my text box loses focus first and the AutoPostBack fires before the Jquery has a chance to change the text in my text box. Is there a way to delay either the PostBack or the Jquery so that they don't fight each other? I'm thinking it may have to be the PostBack that gets changed, since the JQuery would lose it's state on the PostBack. Any suggestions?
Why not remove the ASP.NET autopostback functionality and implement it in JQuery to invoke the post back if/when you want it to post back?

Resources