473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Text box TextChangedEvent not firing

Sue
I have a textbox box and a date picker.When i select a date through
the date picker, it fills the textbox with the selected date.Now, i
have a text changed event for the textbox. This event fires only if i
key in a date manually and not if i use the date picker.

How can i make the textchanged event to fire when i use the date
picker?

Mar 21 '08 #1
2 2082
When a date is selected using the date picker and it fills the TextBox, is
this done using a postback or using JavaScript? If it is done using a
postback, the TextChanged event will not be triggered because the text
didn't change since the last postback. If this is the case, here are several
options:

Option #1: Get the date from the datepicker, this way you can get it as a
Date rather than need to worry about converting a String into a Date. If you
want to allow the user to enter the date manually instead, try following
this process (you may need to add a little validation to make sure you do
not get an error converting from String to Date):

1. Get the date from the date picker
2. In the TextChanged event, use the date from the TextBox

Option #2: You can also try using AJAX, which would be my choice.

Option #3: Write your own control.

Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Sue" <iy*********@hotmail.comwrote in message
news:3d**********************************@q78g2000 hsh.googlegroups.com...
I have a textbox box and a date picker.When i select a date through
the date picker, it fills the textbox with the selected date.Now, i
have a text changed event for the textbox. This event fires only if i
key in a date manually and not if i use the date picker.

How can i make the textchanged event to fire when i use the date
picker?

Mar 21 '08 #2
On 21 Mar, 20:39, Sue <iyer_san...@hotmail.comwrote:
*I have a textbox box and a date picker.When i select a date through
the date picker, it fills the textbox with the selected date.Now, i
have a text changed event for the textbox. This event fires only if i
key in a date manually and not if i use the date picker.

How can i make the textchanged event to fire when i use the date
picker?
Hi

Only one control can trigger a PostBack at any one time and hence
"fire" it's event handler.

No problem!

If you want a piece of code to be executed on the server in response
to more than one control then write a separate routine to handle it
and then put a statement to call the routine in the event handlers of
each control.

For example:

private void SaveDate(DateTime ADate)
{
//code to save date to datasource or whatever
}

protected TextBox1_TextChanged(object sender, EventArgs e)
{
DateTime inputDate = DateTime.Parse(TextBox1.Text);
SaveDate(inputDate);
Calendar1.SelectedDate = inputDate;
Calendar1.VisibleDate = inputDate;
}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
SaveDate(Calendar1.SelectedDate);
TextBox1.Text = Calendar1.Date.ToShortDateString();
}

HTH
Mar 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: qaz | last post by:
For some reason my global.asa file is not firing. I have it located in the root of my website (e.g., wwwroot\mywebsite\global.asa) and I have the web site configured as an "application" in IIS. ...
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
7
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when...
5
by: Datagridtextboxcolumn not firing event | last post by:
"PLEASE HELP, I NEED HELP N O W !!!" AddHandler dgtxtboxcolumn.textbox.KeyDown, AddressOf TextBoxKeyPress Private Sub TextBoxKeyPress(ByVal sender as Object, ByVal e as KeyEventArgs) End...
1
by: thedotnetarchitect | last post by:
Can anyone tell me why my page load event is firing more then once? I have a asp.net 2.0 page with four user controls and it seems that the user controls are loading but the page load event seems...
4
by: Bob | last post by:
Hi, I have already posted a similar problem but it 's still a problem for me, so ... I define a table in aspx file and Javascript code. Purpose: when the user clicks on any cell of the table,...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was...
5
by: Joe | last post by:
Hi I am adding a class to a ComboBox - and all is fine except that I fill the combobox on the Form_Load Method and it causes the method private void comboBox2_SelectedIndexChanged(object...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.