Welcome Guest Search | Active Topics | Sign In | Register

How to Clear The Date Picker Options
PDG
Posted: Tuesday, September 3, 2013 6:35:27 PM
Rank: Advanced Member
Groups: Member

Joined: 12/19/2010
Posts: 47
I have a multiple event application. One such event is to hide controls based on the values of other controls. As those values change dynamically (i.e. Checkbox gets checked), an event is fired and other controls get hidden (ctrl.visible = false). When this sort of event is fired, any value in the control being hidden needs to be cleared. I am having a heck of a time clearing a date picker ctrl. On PageLoad within OnInit, If the date field was created and it's value was set using dp.SelectedDate = <<Some DateTime Object>> to a real date, then it is impossible to clear dynamically. I have tried to clear the date in OnInit after the initial setting, OnPreRender and in the event that fired. The date simply will not clear. All other controls (Dropdown, TextBox, Radio, etc) clear with no problem ... right in the event where they should clear. Only the date picker holds its value. The following code is used to clear the control:

DateTime dt = DateTime.MinValue;
EO.Web.DatePicker dp = (EO.Web.DatePicker)ctrl;
dp.VisibleDate = dt;
dp.SelectedDate = dt;

This came from another post in this forum.

Conversely, if the control is built and then set initially with a blank date, then it can clear during the event postback.

Set Control during Page Load to a real date.
Try and clear the control during a postback.
It will retain it's value.

I will continue to research this. Is this a known issue? Are you able to duplicate this functionality?
eo_support
Posted: Tuesday, September 3, 2013 11:17:37 PM
Rank: Administration
Groups: Administration

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

We are not able to reproduce the problem with the latest build. Our code is as follow:

Code: C#
protected void Page_Load(object sender, EventArgs e)
{
    DatePicker1.SelectedDate = DateTime.Today;
}

protected void Button1_Click(object sender, EventArgs e)
{
    DatePicker1.SelectedDate = DateTime.MinValue;
}


The ASPX code contains a single DatePicker and a Button. When we click Button1 and it correctly clears the DatePicker. Can you try the same code and see if it works for you?

Thanks!
PDG
Posted: Wednesday, September 4, 2013 10:45:16 AM
Rank: Advanced Member
Groups: Member

Joined: 12/19/2010
Posts: 47
Try setting the date picker value in OnInit and not page_load. Controls should be built in OnInit. That is where our controls are built and all other control types clear but the date picker and only when that control has been set during the initial page load (not postback) with a real date. When that control has been set with a real date (in OnInit during the page load), it simply cannot be cleared unless the user manually clears the field. Clearing the field programatically during a postback is not possible.
eo_support
Posted: Wednesday, September 4, 2013 10:58:36 AM
Rank: Administration
Groups: Administration

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

We tested that and it still works fine.

Thanks!
PDG
Posted: Wednesday, September 4, 2013 4:31:15 PM
Rank: Advanced Member
Groups: Member

Joined: 12/19/2010
Posts: 47
Your date picker control was created programatically? Of was it create in the aspx page?
eo_support
Posted: Wednesday, September 4, 2013 4:38:24 PM
Rank: Administration
Groups: Administration

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

It doesn't matter. If a control works correctly when you declare it statically in ASPX, then it will work correctly when you create it programatically. If it doesn't, then the problem is in your code that dynamically creates the control.

The reason that the above is true is because for ASP.NET, every control is created programatically. The only difference is, when you create with your own code, the control is created with your code. When you declare it statically inside ASPX, the control is created with code that ASP.NET automatically generated for you based on your ASPX file. So in the end, everybody is created with code, it's just the code comes from different means.

We have tested to create the control dynamically inside OnInit and it works fine as well.

Thanks!
PDG
Posted: Wednesday, September 4, 2013 4:52:45 PM
Rank: Advanced Member
Groups: Member

Joined: 12/19/2010
Posts: 47
We could debate your first statement, which is only partially correct. However, in the terms of the page lifecycle, aspx controls behave perfectly. They know when to create, update, etc. All of that is up to the programmer when creating controls dynamically. So controls that behave well in aspx, oftentimes do not behave well when created dynamically, especially if your application is complex. Our forms are built with a drag and drop form builder and then dynamically rendered. Each field potentially has hundreds of attributes which leave a ton of room for error. Just getting everything to place nice with ASP.net was major PITA.

I will put together a simple project and see if I can duplicate. If so I will send that to you.
eo_support
Posted: Wednesday, September 4, 2013 5:03:03 PM
Rank: Administration
Groups: Administration

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

I understand your frustration. But you have to understand that ASP.NET sets the rule, the only option you and we have is to play by the rules. We can not change or bend the rules. We absolutely can not make something that behaves differently when the control is created by ASP.NET or by your code --- in fact the control doesn't even know how it is created at all, so even if we would like to do that, it would be very difficult. This is the very reason that if you have a problem when the control is created dynamically, the the problem is absolutely in your code that dynamically creates the control and that's what you will need to fix, and the only option you have. We can not change our control to make it to work for you in this case as we have already mentioned --- we don't even know whether the control is created by your code or created by code dynamically generated by ASP.NET. So it makes no difference to us at all.

Thanks
Mike
Posted: Friday, January 31, 2014 1:44:50 PM
Rank: Member
Groups: Member

Joined: 11/7/2013
Posts: 12
In regards to clearing a datepicker.... there is an 'X' that appears in the right side of the textbox and when clicked it should clear the date and it does. But once you move off the datepicker field, the date reappears in the textbox. The only way to truly clear the date is to highlight each part of the date and delete it. Is that the intended behavior?
eo_support
Posted: Friday, January 31, 2014 4:25:51 PM
Rank: Administration
Groups: Administration

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

No. That is not the intended behavior. The DatePicker does not support the "x" button yet. Older browsers only have a textbox. However newer browser starting from Chrome has a "x" next to textbox as a shortcut to clear the entire textbox. IE 11 followed this approach as well. We have not updated our code to handle this yet. We will look into this and the desired result would be the same as what you expected --- clicking "X" should clear the DatePicker.

Thanks!
eo_support
Posted: Saturday, February 1, 2014 10:53:07 PM
Rank: Administration
Groups: Administration

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

We have posted a new build that supports the "X" button now. You can download the new build from our download page.

Thanks!
Mike
Posted: Wednesday, April 2, 2014 10:38:17 AM
Rank: Member
Groups: Member

Joined: 11/7/2013
Posts: 12
I have applied the 2013 version and multiple servers however, on some of the servers the datepicker is not clearing when I click the 'X'. What am I missing?
eo_support
Posted: Wednesday, April 2, 2014 12:31:02 PM
Rank: Administration
Groups: Administration

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

Make sure you are using the latest build. This was only implemented recently so if you have an older build then it won't clear it. If you believe you are using the latest build but the problem still occurs, you can post the Url (or PM it to us if you do not wish to post it publicly), we can then take a look to see what we can find.

Thanks!
Mike
Posted: Wednesday, April 2, 2014 1:00:19 PM
Rank: Member
Groups: Member

Joined: 11/7/2013
Posts: 12
We have V2013.0.81 and it works on some servers but not others. Very odd. I will keep digging...


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.