%26lt;script runat=';server';%26gt;
Protected Sub Page_Load(ByVal sender As Object,
ByVal e As System.EventArgs)
If (Not Page.IsPostBack) Then
ControlFocus(';txtTable';)
End If
End Sub
Private Sub ControlFocus(ByVal ControlName As String)
Dim f As StringBuilder = New StringBuilder()
f.Append(';%26lt;script language='JavaScript'%26gt;';)
f.Append(';function setFocus() {';)
f.Append(';document.getElementById('';)
f.Append(ControlName)
f.Append(';').focus();}';)
f.Append('; window.onload=setFocus;';)
f.Append(';%26lt;/';)
f.Append(';script%26gt;';)
Page.RegisterStartupScript(';Focus';, focusString.ToString)
End Sub
%26lt;/script%26gt;
However, when I use the above code in my mobile web
application (ASP.NET with VB.NET server code). I am not getting 'focus'in a mobile web TextBox.How to get 'focus' to mobile web control in mobile web form in ASP.Net?
Page.SetFocus() is all you need for ASP.NET. Note that the ability to set focus depends upon the capabilities of the mobile browser. A lot of basic mobile browsers won't support javascript so you may not be able to pull this off as consistenly as you would on a desktop browser.
No comments:
Post a Comment