Our mobile pages have a list box on them to contain all the links a user can click, one of these links is the submit link. This all works fine in IE 6&7, as well as pocket IE on mobile 4&5. However, on our CHTML
capable phones, e.g. Motorola v365, this does not work.
Is it possible to get a link in a CHTML phone to submit the contents of a text box when clicked?
The following is an example form that I put together to show what we are doing in our forms. I have tested it with all of our custom adapters removed and with our custom adapters. All results the same.
<htmlxmlns="http://www.w3.org/1999/xhtml"> <body> <mobile:FormID="Form1" Runat="server"> <mobile:LabelID="Label1" Runat="server">Label</mobile:Label><br
/> <mobile:TextBoxID="TextBox1"
Runat="server" /> <mobile:ListID="List1" Runat="server"
Decoration="Numbered"
OnItemCommand="List1_ItemCommand" /> <br /> </mobile:Form> </body>
</html>
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.Mobile; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.MobileControls; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;
With the Motorola v365 - which has an XHTML browser and not a CHTML browser - your mobile page doesn't post back. Therefore the value of the TextBox is not send to the server.
ASP.NET Mobile Controls always try to detect which device requests the page. Then, if the device is configured, the appropriate mark up is send to it. If the device is not configured and therefore unknown like the Motorola v365 the server sends HTML 3.2
without JavaScript by default. Because JavaScript is used to post back forms with hyperlinks your code doesn't work. CHTML does not allow JavaScript, the Motorola v365 has no JavaScript support and you will not be able to postback with hyperlinks.
To do:
<div mce_keep="true">Determine the user agent of your phones which is used by the server to detect the device</div>
<div mce_keep="true">Check the requests and responses with a HTTP monitoring tool</div>
<div mce_keep="true">Use the Device Profiling Tool to determine the device capabilities and to configure the device</div>
If you like to post back the page without JavaScript you can use a SelectionList (SelectType radio) and a mobile command to submit the page for example.
JavaScriptHyperlinksMobile ListPost backMobile Web Forms
Thank you for your reply, our end result was to go through the applications and replace the submit links with commands as this seemed to be the most approriate thing to do.
Member
2 Points
54 Posts
Submitting data via link in list box
May 31, 2007 01:55 PM|ThisBytes5|LINK
Our mobile pages have a list box on them to contain all the links a user can click, one of these links is the submit link. This all works fine in IE 6&7, as well as pocket IE on mobile 4&5. However, on our CHTML capable phones, e.g. Motorola v365, this does not work.
Is it possible to get a link in a CHTML phone to submit the contents of a text box when clicked?
The following is an example form that I put together to show what we are doing in our forms. I have tested it with all of our custom adapters removed and with our custom adapters. All results the same.
<%@
Page Language="C#" AutoEventWireup="true" Codebehind="Test.aspx.cs" Inherits="Test" %><%@ 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:Label ID="Label1" Runat="server">Label</mobile:Label><br />
<mobile:TextBox ID="TextBox1" Runat="server" />
<mobile:List ID="List1" Runat="server" Decoration="Numbered" OnItemCommand="List1_ItemCommand" />
<br />
</mobile:Form>
</body>
</html>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class Test : MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = string.IsNullOrEmpty(Request.QueryString["Text"]) ? "Null" : Request.QueryString["Text"];
List1.Items.Add(new MobileListItem("Submit"));
}
protected void List1_ItemCommand(object sender, ListCommandEventArgs e)
{
if (e.ListItem.Text == "Submit")
RedirectToMobilePage(string.Format("/public/Test.aspx?Text={0}", TextBox1.Text));
}
}
Participant
1154 Points
433 Posts
Re: Submitting data via link in list box
Jun 01, 2007 02:35 PM|SKT_01|LINK
With the Motorola v365 - which has an XHTML browser and not a CHTML browser - your mobile page doesn't post back. Therefore the value of the TextBox is not send to the server.
ASP.NET Mobile Controls always try to detect which device requests the page. Then, if the device is configured, the appropriate mark up is send to it. If the device is not configured and therefore unknown like the Motorola v365 the server sends HTML 3.2 without JavaScript by default. Because JavaScript is used to post back forms with hyperlinks your code doesn't work. CHTML does not allow JavaScript, the Motorola v365 has no JavaScript support and you will not be able to postback with hyperlinks.
To do:
If you like to post back the page without JavaScript you can use a SelectionList (SelectType radio) and a mobile command to submit the page for example.
JavaScript Hyperlinks Mobile List Post back Mobile Web Forms
Member
2 Points
54 Posts
Re: Submitting data via link in list box
Jun 07, 2007 02:39 PM|ThisBytes5|LINK
Thank you for your reply, our end result was to go through the applications and replace the submit links with commands as this seemed to be the most approriate thing to do.
Thanks
Wayne
Participant
1154 Points
433 Posts
Re: Submitting data via link in list box
Jun 09, 2007 02:15 AM|SKT_01|LINK
Yes. A second option is to use command controls device specific.