Focus() function RRS feed

  • Question

  • User-790167105 posted
    How to use setfocus in mobile asp.net page? I tried set the focus to a control. the system showed that "A form tag with runat=server must exist on the Page to use SetFocus() or the Focus property."
    May I use focus property in a mobile web page
    Thursday, August 31, 2006 9:42 PM

All replies

  • User-2041805088 posted

    I know that the version of Internet Explorer Mobile I have on my PDA phone doesn't support JavaScript, so that could be another thing to look into.


    Saturday, September 2, 2006 12:09 AM
  • User-225480610 posted
    I am having the same problem.  The focus() method causes the error above and trying it with a registered startup javascript fails because ASP doesn't serve up the script (but does serve its own script up).  The mobile device supports javascript.  Was there an answer to the problem?
    Thursday, November 23, 2006 4:43 AM
  • User2026204247 posted


    If you have JavaScript support in you browser try this: 

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <form id="myForm" runat="server">
            <input id="myEdit0" type="text" value="" />
            <input id="myEdit1" type="text" value="" />
            <input id="myEdit2" type="text" value="" />
        <script type="text/javascript">myForm.myEdit1.focus()</script>

    This example working in Windows Mobile 5.

    Best Regards.


    Friday, November 24, 2006 5:05 AM
  • User-225480610 posted

    The solution is in this thread...



    Tuesday, January 2, 2007 8:28 AM