Welcome Guest Search | Active Topics | Sign In | Register

DatePicker SelectedDate ... returning 01/01/0001 Options
Duane
Posted: Friday, April 16, 2010 3:45:30 PM
Rank: Newbie
Groups: Member

Joined: 2/1/2010
Posts: 5
Hello ... I'm using a DatePicker along with a ProgressBar. In the ProgressBar1_RunTask I am calling a method to get the SelectedDate from the DatePicker .... no matter what date I choose I'm getting "01/01/0001" back.

Following is code snippet:



<eo:DatePicker runat="server" ID="fromDate" PickerFormat="MM/dd/yyyy" TitleRightArrowImageUrl="00040102" TitleLeftArrowImageUrl="00040101" TabIndex="2"
DayHeaderFormat="Short" DayCellWidth="22" DayCellHeight="16"
MonthSelectorVisible="True" WeekSelectorVisible="True" TitleLeftArrowDownImageUrl="00040103"
TitleRightArrowDownImageUrl="00040104" Width="100px">
<SelectedDayStyle CssText="background-image:url('00040105');color:white;"></SelectedDayStyle>
<TodayStyle CssText="background-image:url('00040106');"></TodayStyle>
<DisabledDayStyle CssText="COLOR: gray"></DisabledDayStyle>
<TitleStyle CssText="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; PADDING-BOTTOM: 3px; COLOR: white; PADDING-TOP: 3px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #0054e3"></TitleStyle>
<CalendarStyle CssText="border-bottom-color:Black;border-bottom-style:solid;border-bottom-width:1px;border-left-color:Black;border-left-style:solid;border-left-width:1px;border-right-color:Black;border-right-style:solid;border-right-width:1px;border-top-color:Black;border-top-style:solid;border-top-width:1px;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;background-color:white"></CalendarStyle>
<DayHoverStyle CssText="text-decoration:underline"></DayHoverStyle>
<MonthStyle CssText="FONT-SIZE: 8pt; MARGIN: 0px 4px; FONT-FAMILY: Tahoma; cursor:hand"></MonthStyle>
<FooterTemplate>
<div style="FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: Tahoma&quot;">
<img src="{img:00040106}"> Today: {var:today:MM/dd/yyyy}
</div>
</FooterTemplate>
<DayStyle CssText="text-decoration:none"></DayStyle>
<DayHeaderStyle CssText="FONT-SIZE: 11px; COLOR: #0054e3; BORDER-BOTTOM: black 1px solid; FONT-FAMILY: Tahoma"></DayHeaderStyle>
</eo:DatePicker>




Code behind:

protected void ProgressBar1_RunTask(object sender, EO.Web.ProgressTaskEventArgs e)
{
doStuff();
.
.
.
.
}


/* during debug hovering over fromData.SelectedDate gives me 01/01/0001 */
protected void doStuff()
{
string startDate = formatDate(fromDate.SelectedDate.ToShortDateString());
.
.
.
}


Any help would be great ..... thanks ....
eo_support
Posted: Friday, April 16, 2010 6:36:13 PM
Rank: Administration
Groups: Administration

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

ProgressBar will only post back simple form values. In order to get the DatePicker value, you must trigger the progress bar with script and copy the date picker value into a hidden field before triggering the progress bar. It will be something like this:

Code: HTML/ASPX
<!-- This hidden field is used to transfer date picker value  -->
<asp:HiddenField runat="server" ID="hiddenField1" />

<!-- This link is used to trigger the progress bar. 
The progress bar's StartButton is NOT set -->
<a href="javascript:start_task()">Start Task</a>


Code: JavaScript
function start_task()
{
    //Copy DatePicker value into hiddenField1
    var selectedDate = eo_GetObject("DatePicker1").getSelectedDate();
    var hiddenField = 
        document.getElementById("&lt;%=hiddenField1.ClientID%&gt;");
    hiddenField.value = eo_DateToString(selectedDate);

    //Start progress bar
    eo_GetObject("ProgressBar1").startTask();
}


Code: C#
protected void ProgressBar1_RunTask(
    object sender, EO.Web.ProgressTaskEventArgs e)
{
    //Get the value from the hidden field
    DateTime selectedDate = 
        EO.Web.Calendar.StringToDate(hiddenField1.Value);

    ....
}


Hope this helps.

Thanks
Duane
Posted: Monday, April 19, 2010 8:35:52 AM
Rank: Newbie
Groups: Member

Joined: 2/1/2010
Posts: 5
Thanks .... I'll give it a try.


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.