Set focus on mobile page

Discussion in 'ASP .Net Mobile' started by gmengerink@gmail.com, Oct 30, 2007.

  1. Guest

    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
     
    , Oct 30, 2007
    #1
    1. Advertising

  2. JD Guest

    What device are you using?

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


    <> wrote in message
    news:...
    > 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, Nov 4, 2007
    #2
    1. Advertising

  3. Guest

    Thanks for replying.

    I'm using an HP iPaq 6915 with windows mobile 5.0
     
    , Nov 5, 2007
    #3
  4. Steveo Guest

    Hi,
    How have you coded your "isHTML32" DeviceFilter in your Web.config?

    "" wrote:

    > Thanks for replying.
    >
    > I'm using an HP iPaq 6915 with windows mobile 5.0
    >
    >
     
    Steveo, Nov 12, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    4
    Views:
    1,635
    Jason
    May 7, 2007
  2. chen selina
    Replies:
    0
    Views:
    1,339
    chen selina
    Jul 13, 2010
  3. Saud Bahwan Group Computer Services Dept

    How to set focus in the Mobile Web Forms/Web Controls

    Saud Bahwan Group Computer Services Dept, Nov 9, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    181
    Saud Bahwan Group Computer Services Dept
    Nov 9, 2003
  4. Replies:
    2
    Views:
    344
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    338
Loading...

Share This Page