locked
Set focus is posssible in windows Mobile? RRS feed

  • Question

  • User-1285090017 posted

    I have a gridview with 3 coloums, 3rd coloum is link button.

    Requirement:

    When one linkbutton is clicked, focus shoud go to textbox which is at bottom of the page.

    Is that possible, I am using Windows Mobile 6.0.

    Thanks

    Wednesday, November 19, 2008 4:55 AM

Answers

  • User530230881 posted

    dear avicool08, it is very much possible...

    just set the focus to the textbox in the click event of the link button...

    protected void linkbutton_click(object sender, EventArgs e)

    {

    textBoxname.SetFocus();
    }

    hope that helps you...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 21, 2008 4:19 AM

All replies

  • User530230881 posted

    dear avicool08, it is very much possible...

    just set the focus to the textbox in the click event of the link button...

    protected void linkbutton_click(object sender, EventArgs e)

    {

    textBoxname.SetFocus();
    }

    hope that helps you...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 21, 2008 4:19 AM
  • User530230881 posted

    are you using mobile forms or normal asp forms?? if ur using mobile forms please send me urr code as im desperately looking for how to arrange buttons and controls in gridview.. thanks in advance... 

    Friday, November 21, 2008 4:21 AM
  • User-1285090017 posted

    I am using Mobile Forms.

    Simply, I have 3 textboxes, By default TextBox3 should be focused, how to achive this? 

    1    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    2    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    3    
    4    <html xmlns="http://www.w3.org/1999/xhtml" >
    5    <body>
    6        <mobile:Form id="Form1" runat="server">
    7            <mobile:TextBox ID="TextBox1" Runat="server">
    8            </mobile:TextBox>
    9            <mobile:TextBox ID="TextBox2" Runat="server">
    10           </mobile:TextBox>
    11           <mobile:TextBox ID="TextBox3" Runat="server">
    12           </mobile:TextBox>
    13       </mobile:Form>
    14   </body>
    15   </html>
    16   
    

     

     

    Thanks Srikant

    Friday, November 21, 2008 4:49 AM
  • User530230881 posted

    k..

    In the code behind file you'll find the form load event there write the code,

     

    protected void Form_Load(object sender, EventArgs e)

    {

    TextBox3.Focus();
    }

    Friday, November 21, 2008 6:21 AM
  • User-1285090017 posted

    Nope.....

    its showing exception....

     

    Friday, November 21, 2008 7:52 AM
  • User-2122873139 posted

    I had meet the same thing.help[:S]............

    Sunday, December 7, 2008 7:12 AM
  • User1634317999 posted

    Hello,

    unfortunately the focus() method is not supported by IE Mobile under Windows Mobile 5.  But IE Mobile under Windows Mobile 6.x supports this method. Therefore you will not be able to apply this method under WM5.

    Sunday, December 7, 2008 1:14 PM
  • User1634317999 posted

    Hello,

    "The Focus() and SetFocus() functionality is not supported on the mobile forms as this is not handled for all mark ups and devices."

    Therefore you have to apply a workaround:

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test_Focus2.aspx.cs" Inherits="Test_Focus2" %>
    
    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
        <mobile:Form ID="Form1" Runat="server">
            <mobile:TextBox ID="TextBox1" Runat="server">
            </mobile:TextBox>
            <mobile:TextBox ID="TextBox2" Runat="server">
            </mobile:TextBox>
            <mobile:TextBox ID="TextBox3" Runat="server">
            </mobile:TextBox>
            <mobile:Panel ID="Panel2" Runat="server">
                <mobile:DeviceSpecific ID="DeviceSpecific3" Runat="server">
                    <Choice Filter="isHTML32" Xmlns="http://schemas.microsoft.com/mobile/html32template">
                        <ContentTemplate>
    
                            <script type="text/javascript">
                                SetFocus();
                                function SetFocus() {
                                    document.forms[0].TextBox3.focus();
                                }
                            </script>
    
                        </ContentTemplate>
                    </Choice>
                </mobile:DeviceSpecific>
            </mobile:Panel>
        </mobile:Form>
    </body>
    </html>
     
    Sunday, December 7, 2008 2:42 PM
  • User-678012853 posted

    searching for more than a day, finally found the solution,


    ClientScript.RegisterStartupScript(GetType(), "setFocus",

    @"<script FOR=window EVENT=onload>

    document.form1.TextBox2.focus();

    <" + "/script>", false);


    working fine.

    Monday, April 5, 2010 7:47 AM
  • User-1220102473 posted

    ClientScript.RegisterStartupScript(GetType(), "setFocus",

    @"<script FOR=window EVENT=onload>

    document.form1.TextBox2.focus();

    <" + "/script>", false);

    Where put this code?? Can you help me? Please!!!

    Wednesday, September 22, 2010 5:11 PM
  • User-678012853 posted

    window.focus() is working with javascript. for window mobiles script for=window will work.

    use this code on c# where u use

    textbox2.focus()

    Tuesday, October 26, 2010 1:44 PM