I have problems with a form in ASP.net in VB, this form creates dynamic texbox and I have a button to add the textbox. Now this button when adding the new row of textbox saves what has a row before in the BD. Now the question is how can I do so by pressing the "Enter" key to execute the onclick event of my button. Try the DefaultButton property but it only works when the page is refreshed, after clicking on another part of the interface it stops working. I can see that it can be recognized when the "Enter" key is pressed from javascript, but I do not know how to execute the code of the event.
That's the code I have in the botton the name of the event is "AddTextBox" in the Onclick event
<asp:Button ID="btnAdd" runat="server" Text="Add and Save "
OnClick="AddTextBox" />
This would be the CodeBing that contains this button
Protected Sub AddTextBox(sender As Object, e As EventArgs)
'primer panel'
Dim index As Integer = PNLNoNotes.Controls.OfType(Of TextBox)().ToList().Count + 1 'crea una lista que contendra los nombres de los txt dinamicos de panel 1
Me.CreateTextBox("txtPnl1" & index) 'txtPnl1 es el nombre de los txt del panel 1
For Each textBox As TextBox In PNLNoNotes.Controls.OfType(Of TextBox)()
If (textBox.ID = "txtPnl1" + Convert.ToString(index)) Then
textBox.Text = index
algo = index
End If
Next
RecuperarDatos(index)
end sub
Ok now I need to know how I can 1st, detect when the "Enter" key is pressed and secondly know how to send a call or execute this event when the "Enter" key is pressed