PRB: Loss of Query Sting Values When You Use J-PHONE (312099)



The information in this article applies to:

  • Microsoft Mobile Internet Toolkit (MMIT)

This article was previously published under Q312099

SYMPTOMS

When you use the J-PHONE and the J-PHONE emulator, if you append query string values to the Action attribute of a <form> tag and use the HttpRequest.QueryString collection to retrieve the values, no query string values are retrieved.

CAUSE

This problem occurs because of a J-PHONE limitation wherein you cannot append a query string to the URL in the Action attribute of a <form> tag.

RESOLUTION

When you use the J-PHONE and the J-PHONE emulator, use the HttpRequest collection instead of HttpRequest.QueryString to retrieve query string values from the Action attribute of a <form> tag.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new .aspx page named Page1.aspx, and then add the following code:
    <%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" AutoEventWireup="true" %>
    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    
    <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
        <mobile:Form id=Form1 runat="server" Action="QueryString2.aspx?name=value">
    		<mobile:Command ID="command1" Runat=server Text="Submit" />
        </mobile:Form>
    </body>
    
    						
    Notice the Action attribute contains the code Action="QueryString2.aspx?name=value">.
  2. Create a second .aspx page named Page2.aspx, and then add the following code:
    <%@ Page language="c#" Inherits="System.Web.UI.MobileControls.MobilePage" AutoEventWireup="true" %>
    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    
    <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
        <mobile:Form id=Form1 runat="server">
    		<mobile:Label ID="label1" Runat=server />
        </mobile:Form>
    </body>
    <script runat=server>
    void Page_Load(Object sender, EventArgs e)
    {
    	label1.Text = Request.QueryString["name"].ToString();
    }
    </script>
    						
    Notice that this code uses Request["name"].ToString() to retrieve the query string value.
  3. Use the code with the J-PHONE and the J-PHONE emulator. Notice that Page2.aspx cannot retrieve the values that are passed from Page1.aspx. Request.QueryString["name"].ToString() does not return any values.

    Resolution

  4. Replace the code in Page2.aspx with the following code:
    <%@ Page language="c#" Inherits="System.Web.UI.MobileControls.MobilePage" AutoEventWireup="true" %>
    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    
    <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
        <mobile:Form id=Form1 runat="server">
    		<mobile:Label ID="label1" Runat=server />
        </mobile:Form>
    </body>
    <script runat=server>
    void Page_Load(Object sender, EventArgs e)
    {
    	label1.Text = Request["name"].ToString();
    }
    </script>
    						
    This code uses the HttpRequest collection instead of the HttpRequest.QueryString collection.
The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Modification Type:MajorLast Reviewed:6/14/2002
Keywords:kbEmulation kbprb kbWMLDevice KB312099 kbAudDeveloper