Groups | Blog | Home
all groups > asp.net mobile > october 2007 >

asp.net mobile : Set focus on mobile page


gmengerink NO[at]SPAM gmail.com
10/30/2007 4:53:44 AM
There was an article about setting the focus in a mobile page with
this code:
<mobile:Panel id="Panel1" runat="server">
<mobile:DeviceSpecific id="DeviceSpecific1" Runat="server">
<Choice Filter="isHTML32">
<contenttemplate>
<Script for='window' event='onload' language='jscript'>
window.Form1.TB_Location.focus();
</Script>
</contenttemplate>
</Choice>
</mobile:DeviceSpecific>
</mobile:Panel>

This works on my page, but I want to make a page with more than one
textbox
for scanning purpose. Like order numer, article, etc.
I tried to use RegisterStartupScript, with this code:

private void SetFocus(Control FocusControl)
{
string ClientID = FocusControl.ClientID;
System.Text.StringBuilder ScrFocus = new System.Text.StringBuilder();
ScrFocus.Append("<script for='window' event='onload'
language='jscript'>");
ScrFocus.Append("window.Form1.");
ScrFocus.Append(ClientID);
ScrFocus.Append(".focus();");
ScrFocus.Append("</script>");

this.RegisterStartupScript("SetFocus",ScrFocus.ToString());
}

So I can call after scanning the first barcode for textbox1
SetFocus(textbox2);
etc etc.
But the code isn't working.
Is there anyone who nows how and where in my code I can call this
script so I can set the focus of the
cursor in the next textbox after scanning?

With kind regards,

G. Mengerink
JD
11/3/2007 8:50:35 PM
What device are you using?

I know the Blackberry browser does not support focus() for example.


[quoted text, click to view]

gmengerink@gmail.com
11/5/2007 12:34:40 AM
Thanks for replying.

I'm using an HP iPaq 6915 with windows mobile 5.0
Steveo
11/12/2007 7:32:07 AM
Hi,
How have you coded your "isHTML32" DeviceFilter in your Web.config?

[quoted text, click to view]
AddThis Social Bookmark Button