Home/ASP.NET Forums/Advanced ASP.NET/Mobile and Handheld Devices/Mobile TextBox Focus

Mobile TextBox Focus [Answered]RSS

4 replies

Last post Nov 10, 2009 11:04 AM by SKT_01

Please mark as answer if you find this useful.

Thanking You
Tapan Rami
  • freezer27 freezer27

    None

    0 Points

    9 Posts

    Re: Mobile TextBox Focus

    Jul 24, 2009 05:28 PM|freezer27|LINK

    <div> The question is: How can I implement that code in a mobile web form (aspx)?

    This link shows a solution: http://ryanfarley.com/blog/archive/2004/12/21/1325.aspx

    but doesn't work at mobile aspx, only standard asp.net form.
    Actually, I'm testing my mobile web application at any PocketPC, with Windows Mobile 4.2 and 5.0.

    For example:

    protected void Page_Load(object sender, EventArgs e)
    {
    SetFocus(TextBox1);
    }

    This code works in standard asp.net web form, but throws an exception (System.NullReferenceException) in a mobile webform, so, I modify this code at:

    while (!(p is System.Web.UI.MobileControls.TextBox)) p = p.Parent;

    The exception disapears, but the focus doesn't work.
    Please, I need an answer :'(
    My email is freezer27@gmail. com </div>
  • 3amoor 3amoor

    None

    0 Points

    1 Post

    Re: Mobile TextBox Focus

    Nov 10, 2009 01:17 AM|3amoor|LINK

    someone please explain the solution to this... i can't find any answer... i need to set focus on a textbox with asp mobile... i tried everything i could find on the net and it still doesn't work... if anyone got it working please explain!!!!!!!!

    thanks in advance!

    mobile content ASP.NET Mobile Controls Mobile controls asp.net httpbrowsercapabilities ismobiledevice mobile control focus .NET mobile ASP.net Mobile Controls Panel Mobile Device asp.net mobile javascript ASP.NET Mobile

  • SKT_01 SKT_01

    Participant

    1154 Points

    429 Posts

    Re: Mobile TextBox Focus

    Nov 10, 2009 11:04 AM|SKT_01|LINK

    Hello,

    add the following code to a Mobile Web Form:

     

    <mobile:DeviceSpecific ID="DeviceSpecific2" Runat="server">
                <Choice Filter="supportsJavaScript" Xmlns="http://schemas.microsoft.com/mobile/html32template">
                    <ScriptTemplate>
                       <script type="text/javascript">
                           window.onload = function() {
                                document.getElementById('Your_TextBox_Client_Id').focus();
                            }
                        </script>
                    </ScriptTemplate>
                </Choice>
            </mobile:DeviceSpecific>


     

  • ‹ Previous Thread|Next Thread ›