Date TextBox Select On Enter

0
0

I have a regular textbox that I change the input type to a date textbox when entered, so that I can have the placeholder inside of it, however, that causes the “SelectOnEnter” not to work.


' I'm doing this sender cast because I use the same events for multiple fields.
Private Sub DateTxtBox_Enter(sender As Object, e As EventArgs) Handles PaymentDateTxt.Enter
Dim TxtBox As TextBox = CType(sender, TextBox)
If TxtBox.Text.Length = 0 Then
TxtBox.InputType.Type = TextBoxType.Date
End If
End Sub

Private Sub DateTxtBox_Leave(sender As Object, e As EventArgs) Handles PaymentDateTxt.Leave
Dim TxtBox As TextBox = CType(sender, TextBox)
If TxtBox.Text.Length = 0 Then
TxtBox.InputType.Type = TextBoxType.Text
End If
End Sub

I set a breakpoint inside of the ‘click’ event, and that seems to be fired after the ‘enter’ event, so I tried selecting all inside of the click event, no success. Any suggestions? We prefer to use the textbox date input because of the picker style, and the placeholder.

  • You must to post comments
0
0

Hi Kurt,

The placeholder is shown when the textbox is empty and the Date native textbox is managed by the browser, that means depending on what browser you’re using to test the textbox, it can’t be selected.

It’s not a Wisej.NET issue.

Best,
Alaa

  • Kurt
    • Kurt
    • Aug 8, 2023 - 4:23 pm
    I found a solution for this, adding events to the element. I’ve tried so many different ways to add these properly with WiseJ and I’m having a tough time, I can manually add the events to the element with inspect element, and the solution works fine. onfocus=”(this.type=’date’)” onblur=”(this.type=’text’)” I’ve tried using the ClientEvents, InitScript and adding an event listener.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.