RESOLUTION
To resolve this behavior, use a
QueryString variable, and then use server-side code to perform the navigation:
Create a Mobile Web Form with a Link Control
The following code contains a mobile
Link control that is used to navigate to the Page2.aspx page. Notice that the
NavigateURL property of the control specifies the page to which to navigate. This property also contains the
FormNavigateQueryString variable that you set equal to
FormNavigate.
Add the following code sample to an empty .aspx page on your Web server, and then name it Page1.aspx:
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<%@ Page Language="vb" Inherits="System.Web.UI.MobileControls.MobilePage" %>
<mobile:Form id="Form1" runat="server">
<mobile:Link id="Link1" runat="server" NavigateURL="Page2.aspx?FormNavigate=Form2">
Go To Form2
</mobile:Link>
</mobile:Form>
Create a Mobile Web Form
Create a mobile Web Form to which to navigate.
The following code contains two mobile Web Forms to which a user can navigate. The first form is rendered if a
QueryString is not provided when this page is requested. The second form is rendered if a
QueryString that is called
FormNavigate has a value of
Form2.
Add the following code sample to an empty .aspx page, and then name it Page2.aspx:
<%@ Page Language="vb" Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<mobile:Form id="Form1" runat="server">
<mobile:Label id="Label1" runat="server">
Form 1
</mobile:Label>
</mobile:Form>
<mobile:Form id="Form2" runat="server">
<mobile:Label id="Label2" runat="server">
Form 2
</mobile:Label>
</mobile:Form>
Process the QueryString with Microsoft Visual Basic .NET
The following code uses the
Page_Load event to process the
QueryString variable:
To do this, the
QueryString variable called
FormNavigate is retrieved and then stored in a local variable called
navigateToForm. If
navigateToForm is not empty, the
Page.FindControl using
navigateToForm as the argument is called. A reference to the correct form is received, it is stored in a variable called
myForm, and then the
ActiveForm property is set equal to
myForm.
Add the following code sample to the Page2.aspx page after the code that you added in the "Create a Mobile Web Form" section:
<Script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
' Retrieve the QueryString Value
Dim navigateToForm As String
navigateToForm = Request.QueryString("FormNavigate")
' Run navigation code if navigateToForm is not empty
If navigateToForm <> "" Then
Dim myForm As Form
' Find and navigate to the form
myForm = Page.FindControl(navigateToForm)
ActiveForm = myForm
End If
End If
End Sub
</Script>