Answered by:
focus on link control in mobile web form

Question
-
User-731635004 posted
Hi,
I was able to set focus on textbox and selectionlist mobile controls with device specific code
document.Form1.TextBox1.focus()
but this is not working for link controlplease help me to set focus on link control of mobile web form
Thanks,
Dhana
Monday, December 17, 2007 11:07 AM
Answers
-
User113421904 posted
Hi Dhana,
Anchor can have ID attribute, see it helps to use the id to set the focus:
<A id="link1">ASP.NET Mobile Web Form</A>.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 19, 2007 1:06 AM
All replies
-
User113421904 posted
Hi Dhana,
Anchor can have ID attribute, see it helps to use the id to set the focus:
<A id="link1">ASP.NET Mobile Web Form</A>.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 19, 2007 1:06 AM -
User-731635004 posted
Hi Zhao Ji Ma,
I am trying like this
document.Form1.link2.focus()
where link2 is id of Link attribute, if I use anchor also I am getting the same error
error: document.Form1.link2.focus() is a null object.
and further , I am getting another error for anchor : "Id is not a property of anchor "
Thanks,
DhanaWednesday, December 19, 2007 11:38 AM -
User113421904 posted
Hi Dhana,
Yes the ID is not rendered. Fortunately, you can use the ASP.NET Mobile Forms DeviceSpecific to archieve this with the assumption that the code is rendered to HTML. Here is the code.
-------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<%@ 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:Panel ID="Panel1" runat="server"><mobile:DeviceSpecific ID="DeviceSpecificControl" Runat="server">
<Choice Filter="isWML11">
<ContentTemplate>
<!-- WML 1.1 Specific Content -->
</ContentTemplate>
</Choice><Choice Filter="isHTML32">
<ContentTemplate>
<!-- HTML 3.2 Specific Content -->
<A id="link1" href="http://forums.asp.net">ASP.NET Mobile Web Form</A>
</ContentTemplate>
</Choice></mobile:DeviceSpecific>
</mobile:Panel>
</mobile:Form>
</body>
</html>-------------------------------
You need to copy the device filters section from: http://blogs.msdn.com/gurbir/archive/2006/07/26/Gurbir-Singh-Sethi.aspx into the web.config file. The article will also show you how to use ASP.NET Mobile DeviceSpecific.
Friday, December 21, 2007 1:32 AM