Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Place WEBDATEPICKER data in textbox
posted

Hi all,

I have the below code inside my aspx form:

  <asp:TableCell CssClass="WidthTablaFormularioCol2Label">         
                    <ig:WebDatePicker ID="wdpFecha" runat="server" CssClass="CamposRequeridosFormularios" DropDownCalendarID="WebMonthCalendar1" OpenCalendarOnFocus="True" AutoPostBackFlags-EnterKeyDown="Off">
                                 <ClientSideEvents Focus="dtFocus" MouseMove="dtHover" MouseOut="dtOutR" Blur="dtLostFocusR" />                                       
                             </ig:WebDatePicker>
                      <ig:WebMonthCalendar ID="WebMonthCalendar1" runat="server" ChangeMonthToDateClicked="true" EnableMonthDropDown="True" EnableYearDropDown="True">
                       </ig:WebMonthCalendar>
                </asp:TableCell>

 

I need the date that the user can select to place in textbox, I mean the year in one textbox, month in one textbox,etc.

by example:

if the value of webdatepicker is 03/06/2010

i need assigned the value of 03 to a textbox, in other textbox the value of 06 etc..

this should occur whenever the user changes the date from the calendar and updated on TexBox.

Can someone guide me how to do this, if there is an event that is triggered when WEBDATEPICKER change in value, in order to update the textbox


Thanks in Advance

Parents
  • 24497
    Verified Answer
    posted

    Hi Rajwi,

    You may process ClientEvent.ValueChanged and/or others like TextChanged, CalendarClosed, etc. Though, behavior and options availible in evtArgs can be different. In any case in order to get value of editor, you can always use sender.get_value().

    Below I wrote example for you which uses ValueChanged.
    Note: if you intend to use shared drop down calendar (like in my sample) and you are going to use <% %> in javascript (like in my sample), then you should wrap script block into element with runat='server', otherwise, framework of dot net will prevent building global dynamic controls and shared calendar will not be avaiable.

    <span runat="server" style="dislay:none">
    <script type="text/javascript">
    function WebDatePicker1_ValueChanged(sender, eventArgs)
    {
     var value = eventArgs.get_value();
     //var value = sender.get_value();
     //var oldValue = eventArgs.get_oldValue();
     var y = '', m = '', d = '';
     if (value)
     {
      y = value.getFullYear();
      m = value.getMonth() + 1;
      d = value.getDate();
      if(m < 10)
       m = '0' + m;
      if(d < 10)
       d = '0' + d;
     }
     var elemY = $get('<%=TextBox1.ClientID%>');
     var elemM = $get('<%=TextBox2.ClientID%>');
     var elemD = $get('<%=TextBox3.ClientID%>');
     if(elemY)
      elemY.value = y;
     if(elemM)
      elemM.value = m;
     if(elemD)
      elemD.value = d;
    }
    </script>
    </span>
    <ig:WebDatePicker ID="WebDatePicker1" runat="server">
     <ClientSideEvents ValueChanged="WebDatePicker1_ValueChanged"  />
    </ig:WebDatePicker>
    <br />
    Year:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
    Month:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
    Day:<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

     

Reply Children
No Data