DatePicker Submit

Hi I am using RadzenDatePicker,
When a date is typed in manually and you press Enter, the change is not saved (not bound).
But tab out of the input before pressing Enter or pick a date using the mouse it works.

Hi @bikash_paudyal
It looks like this might be related to how the value is being bound. If you’re relying on manual typing and pressing Enter, the change won’t trigger unless the component is inside a <RadzenTemplateForm> with a proper Submit handler, or unless the binding is handled explicitly.

Could you share a bit more of your code (the DatePicker and how it’s bound)? That would help in pinpointing the exact cause.

HI @Gurjeet_Singh below is the my code:


<EditForm Model="oEmp" OnValidSubmit="HandleValidSubmit">

 <RadzenRow Gap="0.2rem" RowGap="0.2rem">
     <RadzenStack Style="width:8rem">
         <RadzenFormField AllowFloatingLabel="false" Text="DOB">
             <RadzenDatePicker DateFormat="dd-MM-yyyy" Name="empdob" ShowTime=false @bind-Value="@oEmp.EmpDoB"></RadzenDatePicker>
         </RadzenFormField>
         <ValidationMessage For="@(() => oEmp.EmpDoB)"></ValidationMessage>
     </RadzenStack>
 </RadzenRow>
 <RadzenStack class="rz-mt-4" Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Start">
    <RadzenButton ButtonStyle="ButtonStyle.Primary" ButtonType="ButtonType.Submit" Size="ButtonSize.Medium">Submit</RadzenButton>
</RadzenStack>
</EditForm>

public partial class Employee
{
 public DateTime EmpDoB { get; set; }
 
}

Hi,

Yes, that’s possible. But keep in mind that once you handle the Enter key, it will no longer open the date picker popup.

To make the form submit on Enter, you can attach a KeyDown event to the RadzenDatePicker and call your submit logic (or any other action you need) inside that handler.

ref added below:

Your screenshot doesn’t actually show how the KeyDown attribute is done to call the OnKeyDown method and pass the appropriate arguments. Can you include that bit?