MobilePage.ActiveForm Proprietà

Definizione

Ottiene o imposta il form attualmente attivo della pagina. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con ASP.NET.

public:
 property System::Web::UI::MobileControls::Form ^ ActiveForm { System::Web::UI::MobileControls::Form ^ get(); void set(System::Web::UI::MobileControls::Form ^ value); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public System.Web.UI.MobileControls.Form ActiveForm { get; set; }
[<System.ComponentModel.Bindable(false)>]
[<System.ComponentModel.Browsable(false)>]
member this.ActiveForm : System.Web.UI.MobileControls.Form with get, set
Public Property ActiveForm As Form

Valore della proprietà

Form della pagina attualmente attivo.

Attributi

Eccezioni

La pagina non contiene form.

Esempio

Nell'esempio seguente viene illustrato come utilizzare la ActiveForm proprietà di un Form controllo . Se il dispositivo mobile corrente consente le chiavi di accesso per i controlli, il pulsante visualizzerà la chiave di accesso che invia il modulo.

Nota

L'esempio di codice seguente usa il modello di codice a file singolo e potrebbe non funzionare correttamente se copiato direttamente in un file code-behind. Questo esempio di codice deve essere copiato in un file di testo vuoto con estensione aspx. Per altre informazioni, vedere Web Forms ASP.NET Page Code Model.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
    // <Snippet2>
    private void Command_OnClick(object sender, EventArgs e)
    {
        // Display the other form
        if (ActiveForm.ID == "Form1")
            ActiveForm = Form2;
        else
            ActiveForm = Form1;
    }
    // </Snippet2>

    public bool isAccessKey(MobileCapabilities caps, 
        string optValue)
    {
        // Determine if the browser is not a Web crawler 
        // and can use access keys
        if (!caps.Crawler && caps.SupportsAccesskeyAttribute)
            return true;
        return false;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1" >
        <mobile:Label Runat="server">This is Form1</mobile:Label>
        <mobile:Command id="cmd1" runat="server" Text="No AccessKey" 
            onClick="Command_OnClick">
            <DeviceSpecific>
               <Choice Filter="isAccessKey" Text="AccessKey is 1"/>
            </DeviceSpecific>
        </mobile:Command>
        <mobile:Label id="Label1" runat="server" />
    </mobile:Form>
    <mobile:Form ID="Form2" Runat="server">
        <mobile:Label Runat="server">This is Form2</mobile:Label>
        <mobile:Command id="cmd2" runat="server" text="Back to Form1"
            onClick="Command_OnClick">
            <DeviceSpecific>
                <Choice Filter="isAccessKey" Text="1 is AccessKey" AccessKey="1" />
            </DeviceSpecific>
        </mobile:Command>
    </mobile:Form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
    ' <Snippet2>
    Private Sub Command_OnClick(ByVal sender As Object, ByVal e As EventArgs)
        ' Display the other form
        If ActiveForm.ID = "Form1" Then
            ActiveForm = Form2
        Else
            ActiveForm = Form1
        End If
    End Sub
    ' </Snippet2>

    Public Function isAccessKey(ByVal caps As MobileCapabilities, _
        ByVal optValue As String) As Boolean
        
        ' Determine if the browser is not a Web crawler 
        ' and can use access keys
        If Not caps.Crawler AndAlso caps.SupportsAccesskeyAttribute Then
            Return True
        End If
        Return False
    End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1" >
        <mobile:Label ID="Label1" Runat="server">This is Form1</mobile:Label>
        <mobile:Command id="cmd1" runat="server" Text="No AccessKey" 
            onClick="Command_OnClick">
            <DeviceSpecific>
               <Choice Filter="isAccessKey" Text="AccessKey is 1"/>
            </DeviceSpecific>
        </mobile:Command>
        <mobile:Label id="Label2" runat="server" />
    </mobile:Form>
    <mobile:Form ID="Form2" Runat="server">
        <mobile:Label ID="Label3" Runat="server">This is Form2</mobile:Label>
        <mobile:Command id="cmd2" runat="server" text="Back to Form1"
            onClick="Command_OnClick">
            <DeviceSpecific>
                <Choice Filter="isAccessKey" Text="1 is AccessKey" AccessKey="1" />
            </DeviceSpecific>
        </mobile:Command>
    </mobile:Form>
</body>
</html>

Commenti

Quando viene inizialmente eseguito il rendering di una pagina, il primo modulo nella pagina viene automaticamente attivato. Nei postback successivi, un altro modulo può essere reso attivo, impostando questa proprietà a livello di codice o in seguito all'esplorazione dell'utente tramite un Link controllo .

Si applica a

Vedi anche