ActiveForm Property
Gets or sets the page's currently active form.
public System.Web.UI.MobileControls.Form ActiveForm {
get,
set
}
Remarks
When a page is initially rendered, the first form in the page is automatically made active. On subsequent postbacks, another form might be made active, either by programmatically setting this property, or as a result of user navigation through a Link control.
Example
The following example demonstrates how to use the ActiveForm property of a Form control. The ActiveForm property is set in the button click. This technique is useful when you have multiple pages involved in an application with session variables shared among them.
<script language=vb runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack
Session("formid") = "0"
End If
If (Session("formid") = "0")
ActiveForm = Form1
Session("formid") = "1"
Else If (Session("formid") = "1")
ActiveForm = Form2
Session("formid") = "0"
End If
End Sub
</script>
<mobile:form id="Form1" runat=server >
<mobile:label id=Label1 runat=server Text="Welcome 1"/>
<mobile:Command runat=server Text="Go to Form2" />
</mobile:form>
<mobile:form id="Form2" runat=server >
<mobile:label id=Label2 runat=server Text="Welcome 2"/>
<mobile:Command runat=server Text="Go to Form1" />
</mobile:form>
[C#]
<script language="c#" runat=server>
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
Session["formid"] = "0";
if(Session["formid"] == "0")
{
ActiveForm = Form1;
Session["formid"] = "1";
}
else if(Session["formid"] == "1")
{
ActiveForm = Form2;
Session["formid"] = "0";
}
}
</script>
<mobile:form id="Form1" runat=server >
<mobile:label id=Label1 runat=server Text="Welcome 1"/>
<mobile:Command runat=server Text="Go to Form2" />
</mobile:form>
<mobile:form id="Form2" runat=server >
<mobile:label id=Label2 runat=server Text="Welcome 2"/>
<mobile:Command runat=server Text="Go to Form1" />
</mobile:form>
See Also
Applies to: MobilePage Class