Welcome Guest Search | Active Topics | Sign In | Register

OnSelectionChanged in DatePicker Options
Matt at GMI
Posted: Monday, April 28, 2008 9:16:03 AM
Rank: Newbie
Groups: Member

Joined: 1/30/2008
Posts: 6
I am trying to use the OnSelectionChanged in the DatePicker, but when I set the SelectedDateString OnSelectionChanged no longer works. The value itself would still change before creating adding the OnSelectionChanged value, the AutoPostbackOnSelect still takes place, and without the SelectedDateString the OnSelectionChanged works.

<asp:TemplateField HeaderText="Depart">
<EditItemTemplate>
<eo:DatePicker runat="server" id="DatePickerTravelArrivalDate" TitleLeftArrowHtml="" TitleRightArrowHtml=""
DayHeaderFormat="Short" OtherMonthDayVisible="False" DayCellWidth="31"
DayCellHeight="15" TitleFormat="MMMM, yyyy" Width="100px"
MinValidDate="2009-04-10" MaxValidDate="2009-04-13"
FirstMonth="2009-04-01" LastMonth="2009-04-01"
SelectedDateString='<%# Bind("TravelArrivalDate") %>'
OnSelectionChanged="DatePickerTravelArrivalDateGU_SelectionChanged" AutoPostbackOnSelect="true">
<SelectedDayStyle CssText="background-image:url('00040403');color:brown;"/>
<TodayStyle CssText="background-image:url('00040401');color:#1176db;"/>
<TitleArrowStyle CssText="cursor:hand;"/>
<DisabledDayStyle CssText="color:gray;"/>
<TitleStyle CssText="font-family:Verdana;font-size:8.75pt;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;"/>
<CalendarStyle CssText="background-color:white;border-bottom-color:Silver;border-bottom-style:solid;border-bottom-width:1px;border-left-color:Silver;border-left-style:solid;border-left-width:1px;border-right-color:Silver;border-right-style:solid;border-right-width:1px;border-top-color:Silver;border-top-style:solid;border-top-width:1px;color:#2C0B1E;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;"/>
<DayHoverStyle CssText="cursor:hand;background-image:url('00040402');color:#1c7cdc;"/>
<MonthStyle CssText="font-family:Verdana;font-size:8pt;margin-bottom:0px;margin-left:4px;margin-right:4px;margin-top:0px;"/>
<DayStyle CssText="color:#666666;font-weight:bold;"/>
<FooterTemplate>
<table border="0" cellpadding="0" cellspacing="5" width="100%" style="font-family:verdana;font-size:8pt;">
<tr>
<td valign="middle" style="text-align:center;">Today: {var:today:MM/dd/yyyy}</td>
</tr>
</table>
</FooterTemplate>
<DayHeaderStyle CssText="border-bottom: #f5f5f5 1px solid"/>
</eo:DatePicker>
<asp:DropDownList ID="DropDownListTravelArrivalDate" SelectedValue='<%# Bind("TravelArrivalDate", "{0:t}") %>' OnInit='<%# CreateTimesGU("DropDownListTravelArrivalDate") %>' OnSelectedIndexChanged="DropDownListTravelArrivalDateGU_SelectedIndexChanged" AutoPostBack="true" runat="server"></asp:DropDownList>
<asp:TextBox ID="TextBoxTravelArrivalDate" Text='<%# Bind("TravelArrivalDate", "{0:MM/dd/yyyy} {0:t}") %>' ReadOnly="true" runat="server" />
</EditItemTemplate>
<ItemTemplate><%# Eval("TravelArrivalDate", "{0:MM/dd/yyyy} {0:t}").ToString() %></ItemTemplate>
</asp:TemplateField>

protected void DatePickerTravelArrivalDateGU_SelectionChanged(object sender, EventArgs e)
{
EO.Web.DatePicker dPicker = (EO.Web.DatePicker)sender;
TextBox tBox = AccessDetailsView7_GU.FindControl("TextBoxTravelArrivalDate") as TextBox;
String stringVariable = String.Empty;
String stringOfChars = " ";
char[] charArray = stringOfChars.ToCharArray();
String[] stringArray = tBox.Text.Split(charArray, 2);
if (dPicker.SelectedDateString.Equals(String.Empty))
{
tBox.Text = "";
}
else
{
tBox.Text = dPicker.SelectedDateString + " " + stringArray[1].ToString();
}
}
eo_support
Posted: Monday, April 28, 2008 9:20:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

That's interesting. We will take a look and get back to you as soon as possible.

Thanks
eo_support
Posted: Thursday, May 1, 2008 2:30:47 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

We looked into it and it appears to be working fine here. Check your DataBind calls. SelectedDateString='<%# Bind("TravelArrivalDate") %>' get executed every time DataBind() is called, either implicitly or explicitly. When it is called, it resets the DatePicker's SelectedDate to the value from the data source, which would wipe out the new value you have selected.

Thanks
Matt at GMI
Posted: Friday, May 2, 2008 7:07:33 AM
Rank: Newbie
Groups: Member

Joined: 1/30/2008
Posts: 6
Perhaps I didn't state that quite right...

The date will change in your field and it is also set to activate the fuction as well. But then it will not change the date in the field I added via the "OnSelectionChanged" function I have created. So to further test this I changed the function to this:
public void DatePickerTravelArrivalDateGU_SelectionChanged(object sender, EventArgs e)
{
Response.Redirect("http://www.gmitravelinc.com/");
}
It still doesn't work. Is there a way it can?
eo_support
Posted: Friday, May 2, 2008 7:15:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

We are still quite confused about what you are talking about...Can you create a sample project that reproduces the problem? We will take a look as soon as we have that.

Thanks
Matt at GMI
Posted: Friday, May 2, 2008 7:31:34 AM
Rank: Newbie
Groups: Member

Joined: 1/30/2008
Posts: 6
Go here:
https://www.gmitravelinc.com/gmi/demo/reports/all-data-update-details.aspx?confirmation=10281

Click on "Edit" under "Air Reservations".
Change the date in the field labeled "Depart from Home" from "04/12/2009" to any of the available ones listed.

The "OnSelectionChanged" function is the one I just listed to redirect to "http://www.gmitravelinc.com/", where originally it was supposed to change the date in the open field with the date and time.

Change the date in the field labeled "Return to Home" from "04/20/2009" to any of the available ones listed.

The "OnSelectionChanged" function is the original one that should change the date in the field there.

Both autopostback, but neither function.
eo_support
Posted: Friday, May 2, 2008 7:38:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

I think we got what you mean, but we need to debug your server side code in order to find out why it's doing that. We can setup an online meeting for you so that you can share your desktop with us, please let us know if you are OK with that.

Thanks
Matt at GMI
Posted: Friday, May 2, 2008 7:43:14 AM
Rank: Newbie
Groups: Member

Joined: 1/30/2008
Posts: 6
Not sure I can do that for security reasons. Can I send you the code from the files themselves?
eo_support
Posted: Friday, May 2, 2008 7:48:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Definitely yes. That is actually better because we will be able to debug not only through your code, but also our code. But please make sure the code you sent to us runs. The issue does not appear to be a simple one, so we do not think we can really dig out too much without being able to run and debug through it --- that's also why we were asking for a reproducing sample.
eo_support
Posted: Friday, May 2, 2008 1:22:54 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

We have received your sample code and looked into it. The issue is triggered by view state instead of SelectedDateString. You have view state disabled on the page and OnSelectionChanged won't work without that because it stores some information needed to compare values (thus triggering the "changed" event) in the view state. We will look into it and see if we can remove that restriction, but in the mean time if you enable view state on your page the event should start to work.

Thanks
Matt at GMI
Posted: Friday, May 2, 2008 1:33:01 PM
Rank: Newbie
Groups: Member

Joined: 1/30/2008
Posts: 6
In many cases of ASP.NET 2.0 many developers don't want to use the ViewState because it adds major amounts of data to the page and makes the pages excessivly HUGE. Is there a way you could let us not have to use the ViewState with the DatePicker? Right now your control is the only one that I would have to use the ViewState for on any of my reports or my major sites and I would rather not have to turn it on because it would more than triple the size of the pages.

Microsoft created the ControlState to be used instead of the ViewState to be used as one option -- could that be used in some way for the ASP.NET 2.0 DatePicker users?

Thanks.
eo_support
Posted: Friday, May 2, 2008 1:51:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi,

We understand that. Unfortunately for the current version, the only way to use this without view state is to store the previous value somewhere (for example, hidden field), then compare the new value and old value and fire the event manually. We will also try to workaround it on our side so that it no longer requires view states; So you can also wait on that, but we do not have an ETA yet since it will take more time to get a clear view on what needs to be changed.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.