[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Re: Mobile TextBox Initial Focus

(Earl Beaman[MS])

12/23/2002 10:44:00 PM

Hi Eric,

I have some information for you regarding this issue.

#1 Always test on the device and not IE. PocketPC devices only support a
subset of IE's DOM object model and events.

#2 The Enter key will not submit the form to the server. This simply won't
work on Pocket IE.

You can use the Text_Changed event, but only after focus changes to another
control. Thus, you will not be able to see the carriage return
/termination character from the barcode scanner in your code until the user
clicks another control.

Use the following code to set focus to a control in the onload event.

<mobile:Form id="Form1" runat="server">
<mobile:Panel id="Panel1" runat="server">
<mobile:DeviceSpecific id="DeviceSpecific1" Runat="server">
<Choice Filter="isHTML32">
<contenttemplate>
<Script for="window" event="onload" language="jscript">
window.alert("HI");
window.Form1.TextBox1.focus();
</Script>
</contenttemplate>
</Choice>
</mobile:DeviceSpecific>
</mobile:Panel>
<mobile:TextBox id="TextBox1" runat="server"
text="mobile:TextBox1"></mobile:TextBox>
<mobile:TextBox id="TextBox2" runat="server"
text="mobile:TextBox2"></mobile:TextBox>
</mobile:Form>

Note that the textboxes are outside of the panel and the device specific.
This avoids names like "_ctl0:TextBox1". You cannot use a name like this
to set focus to a particular control.

An approach that works fairly well is to create a control that simply emits
a javascript statement to set focus to a control specified in the focus
control's properties. This control would have to be the last control on
the page to work correctly.

Earl Beaman
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.