Another SetFocus question RRS feed

  • Question

  • User731069546 posted

    I have read answers to most of the setfocus questions on thsi forum but still confused. This is what I have in my regular ASP.NET code.

    Public Sub SetFocus(ByVal control As WebControl)

    Dim script As String = "<script language=" + Chr(34) + "JavaScript" + Chr(34) + ">" + _

    " var control = document.getElementById(" + Chr(34) + control.ClientID + Chr(34) + ");" + _

    " if (control != null) { control.focus();}" + _


    Page.RegisterStartupScript("Focus", script)

    End Sub

     Now I can set focus to a particular text box on my web page during the page load function.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

    Now how can do similar thing in ASP.NET Mobile? I see that I need to define a device filter for Javascript but still stumped on how to proceed with this. Any help is much appreciated.


    Friday, March 16, 2007 11:17 AM

All replies

  • User731069546 posted
    Wednesday, March 21, 2007 5:21 PM
  • User-1179442337 posted

    this is one of those questions that is browser/device specific, meaning does the browser/device have support for javascript. -meaning make checks if the browser/device supports javascript? if it does, the code should work? if it does not , it will not work? -on the other hand, what is it exactly, that you want the mobile device to do?

    Thursday, March 22, 2007 1:06 AM
  • User731069546 posted

    Well the device does supports javascript. I am just looking at ways to modify this code so that it would work on my mobile device. You saying if my device supports javascript then the presented code should work as is?

    What I want to do is set the focus to a particular control when user clicks some button on my page. On PC based app, I have it setup so that ENTER key causes focus to move to the next control. Something similar would really be awesome but I would take a solution where I can programmatically set the focus to any control that I want.

    Any help with that would be appreciated.

    Thursday, March 22, 2007 10:20 AM