Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Default ENTER key press to button click event
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Divers
Thread ID:
00872282
Message ID:
00873835
Vues:
44
Hi Cathi,

I left some stuff out of the picture. I have a slider menu and a little server side generated javascript (setfocus) that sets focus to the 1 and only textbox of my web form. I was scripting out the javascript during the Page_load event in postback and when !IsPostBack=true. If I remove both the slider menu and the setfocus script, _eventtarget works as expected. I will have to work a little harder at this one. I will update you. Any thoughts?

I also have noticed that when my form spawns a small browser window and I attempt to bring this browser window into focus, via a postedback-generated script (!IsPostBack=true and false) via SpawnedWinHandle.focus() ( that's javascript), that the spawned browser window will not receieve focus and the main browser remains on top. That is if I attempt to set focus to the textbox during a postback. If I set focus to the textbox when !IsPostBack = true, the _EVENTTARGET works and I can set focus to the spawned browser window when the page opens one. All I need to do is wrap my set focus of the textbox and set focus of the browser window routines in a "if(!IsPostBack)" condition. What is it about this postback stuff?

>Neil,
>
>That's odd. When I change from Button2 to Button1, it works as expected. Then when I change from Button1 to Button2, it also works as expected. I'm not seeing the same behavior you are.
>
>>Hi Cathi,
>>
>>I will work on this over the weekend. I have also experienced some interesting behavior on a third form. The third form has 1 textbox and 2 buttons. I coded:
>>
>>Page.RegisterHiddenField("__EVENTTARGET", "button1");
>>
>>When I press the ENTER key the click event for button2 fires. Does that help you at all?
>>
>>Regards,
>>Neil
>>
>>>Hi Neil,
>>>
>>>I just created a sample app with one textbox and two buttons. Using the technique below, it worked as expected. I'm not sure what you are doing different.
>>>
>>>>Thank you Cathi,
>>>>
>>>>This works great when your web form contains more than 1 texbox. I however have 2 web forms that only contain 1 texbox each. I need a technique to default the ENTER key to activate a button's click event on web forms that only have 1 textbox.
>>>>
>>>>Neil
>>>>
>>>>>Hi Neil,
>>>>>
>>>>>The C# version would just have a semicolon after the line.
>>>>>
>>>>>>That is wild. Thank you. Any chance at a c# incarnation or is it basically the same?
>>>>>>
>>>>>>Neil
>>>>>>
>>>>>>>I found this code here long time ago:
>>>>>>>
>>>>>>>
>>>>>>>   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
>>>>>>>
>>>>>>>        ' This causes the page to associate Enter key with cmdAddIt button click event.
>>>>>>>        ' (source: Universal Thread Message ID: 814613, http://www.levelextreme.com)
>>>>>>>        Page.RegisterHiddenField("__EVENTTARGET", "cmdAddIt")
>>>>>>>
>>>>>>>    End Sub
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>Also, take a look at thread 849502
>>>>>>>
>>>>>>>
>>>>>>>>Hi,
>>>>>>>>
>>>>>>>>I have a web form with a 2 buttons: CLOSE (btnClose) and SAVE (btnSave). I would like the ENTER key on the keyboard to fire the click event of the SAVE button. What property do I set to make the ENTER key the default. OR... do I need to include a method in an event handler.
>>>>>>>>
>>>>>>>>Regards,
>>>>>>>>Neil
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform