Link to home
Start Free TrialLog in
Avatar of jackrock79
jackrock79

asked on

Textbox Textchanged event doesn't fire...

Hi There,
I have two textboxes and two image buttons for the date selections. The two image buttons when cliked open a window (one at a time) which has the calendar.aspx page and this window returns the value of the date selection made and populates it into the textboxes. My ques is the textchanged event doesn't fire for the second text box. Also the textchanged event fires only after the second image button is clicked. Can anybody please suggest me how to deal this problem?

This is the code.which I am working on ..

StartDateCalendar, EndDate Calendar are two image butons...txtStartDate, txtEndDate are two textboxes

---aspx---
<asp:textbox id=txtStartDate runat="server" AutoPostBack="True" ReadOnly="true"  OnTextChanged=txtStartDate_TextChanged></asp:textbox>
<asp:imagebutton id=StartDateCalendar ImageUrl="../../../Resources/Images/Calendar.gif" CausesValidation="false"></asp:imagebutton>
<asp:textbox id=txtEndDate runat="server" AutoPostBack="True" ReadOnly="true"  OnTextChanged=txtEndDate_TextChanged></asp:textbox>
<asp:imagebutton id=EndDateCalendar runat="server" ImageUrl="../../../Resources/Images/Calendar.gif" CausesValidation="false"></asp:imagebutton>

--aspx.cs
StartDateCalendar.Attributes["onclick"] = "window.open('../Calendar.aspx?textbox=txtStartDate','cal','width=200,height=200,left=70,top=80');";
EndDateCalendar.Attributes["onclick"] = "window.open('../Calendar.aspx?textbox=txtEndDate','cal','width=200,height=200,left=70,top=80');";


----In calendar.aspx.cs...
//Hidden control
control.Value = Request.QueryString["textbox"].ToString();

private void calDate_SelectionChanged(object sender, System.EventArgs e)
            {
                  //System.DateTime dtDate = calDate.SelectedDate;
                  string strScript = "<script>window.opener.document.forms(0)." + control.Value + ".value = '";
                  strScript += calDate.SelectedDate.ToString("MM/dd/yyyy");
                  strScript += "';self.close()";
                  strScript += "</" + "script>";
                  this.RegisterClientScriptBlock("anything",strScript);
                  

}

Thanks a lot
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of praneetha
praneetha

Avatar of jackrock79

ASKER

The prob I am having is..If the user makes a selection of the dates and rather than doing smth on this page..if he goes back to some other page..I guess the textchanged events do not fire..So how shud I handle this issue?? I mean to say..I would like to remeber the dates chosen and populate them on the other page...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
User navigates to the other page by clicking the link on the header. I can store the values(date selections) in session and pass them..but where am I supposed to capture those values?? I tried to do that in the onchange event of the textbox, but for some reason it wouldn't fire that event?
well you can write in calendar.asx in selection change event..

if the only only they can pick a date is using calendar pop up..instead of using keyboard...

hmm instead if they can change using keyboard...just put this in text changed event...since it woud fire it then...

or if the use calendar...the code in selection changed event fires..
Thanks guys for your suggestions...I couldn't capture the values in the textchanged event of the textbox as the textchanged events are not fired for some reason.. But I did capture them in the selection changed event for the calendar.
I am sorry..I meant to accept the final suggestion made by Praneetha..
Thanks