更新:2007 年 11 月
如果在用户控件所包含的控件中具有 #form1 格式的链接,则 ResolveFormReference 方法在用户控件中查找其 ID 属性设置为 form1 的窗体。如果没有找到这样的窗体,则此方法上移到嵌套的用户控件链,然后在该页上搜索窗体。若要链接在用户控件中包含的窗体,请使用以下语法来标识该窗体。
#mc1:form4
mc1 是用户控件标识符。冒号 (:) 分隔对窗体的引用。
说明: |
|---|
不支持元素定位点(窗体 page.aspx#element 的 URL,其中 page 不是当前页)。 |
示例
下面的代码示例演示窗体之间的定位。该示例包含一个移动网页和一个移动用户控件。
Formtest.aspx
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Register TagPrefix="uc1" TagName="MobileWebUserControl1"
Src="formtest.ascx" %>
<script runat="server">
void Form_Activate(Object sender, EventArgs e)
{
((Form)sender).DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:form id="Form1" runat="server"
OnActivate="Form_Activate">
<mobile:Label ID="Label1" runat="server"
Text='<%# "Current: " + ActiveForm.UniqueID %>' />
<mobile:Link ID="Link1" href="#form2"
runat="server">Go to Form 2</mobile:Link>
<mobile:Link ID="Link2" href="#form3"
runat="server">Go to Form 3</mobile:Link>
<mobile:Link ID="Link3" href="#mc1:form4"
runat="server">Go to Form 4</mobile:Link>
/mobile:form>
<mobile:Form ID="Form2" Runat="server"
OnActivate="Form_Activate">
<mobile:Label ID="Label2" runat="server"
Text='<%# "Current: " + ActiveForm.UniqueID %>' />
<mobile:Link ID="Link4" href="#form1"
runat="server">Go to Form 1</mobile:Link>
<mobile:Link ID="Link5" href="#form3"
runat="server">Go to Form 3</mobile:Link>
<mobile:Link ID="Link6" href="#mc1:form4"
runat="server">Go to Form 4</mobile:Link>
</mobile:Form>
<mobile:Form ID="Form3" Runat="server"
OnActivate="Form_Activate">
<mobile:Label ID="Label3" Runat="server"
Text='<%# "Current: " + ActiveForm.UniqueID %>'>
</mobile:Label>
<mobile:Link ID="Link7" href="#form1"
Runat="server" >Go to Form 1</mobile:Link>
<mobile:Link ID="Link8" href="#form2"
Runat="server" >Go to Form 2</mobile:Link>
<mobile:Link ID="Link9" href="#mc1:form4"
Runat="server" >Go to Form 4</mobile:Link>
</mobile:Form>
<uc1:MobileWebUserControl1 id="mc1" runat="server" />
</body>
</html>
Formtest.ascx
<%@ Control Language="C#" ClassName="FormTest"
Inherits="System.Web.UI.MobileControls.MobileUserControl" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
void Form_Activate(Object sender, EventArgs e)
{
((Form)sender).DataBind();
}
</script>
<mobile:Form ID="Form4" Runat="server" OnActivate="Form_Activate">
<mobile:Label ID="Label1" runat="server"
Text='<%# "Current: " +
((MobilePage)Page).ActiveForm.UniqueID %>' />
<mobile:Link ID="Link1" href="#form1"
runat="server">Go to Form 1</mobile:Link>
<mobile:Link ID="Link2" href="#form2"
runat="server">Go to Form 2</mobile:Link>
<mobile:Link ID="Link3" href="#form3"
runat="server">Go to Form 3</mobile:Link>
<mobile:Link ID="Link4" href="#form4a"
runat="server">Go to Form 4a</mobile:Link>
</mobile:Form>
<mobile:Form ID="Form4a" Runat="server" OnActivate="Form_Activate">
<mobile:Label ID="Label" runat="server"
Text='<%# "Current: " +
((MobilePage)Page).ActiveForm.UniqueID %>' />
<mobile:Link ID="Link5" href="#form1"
runat="server">Go to Form 1</mobile:Link>
<mobile:Link ID="Link6" href="#form2"
runat="server">Go to Form 2</mobile:Link>
<mobile:Link ID="Link7" href="#form3"
runat="server">Go to Form 3</mobile:Link>
<mobile:Link ID="Link8" href="#form4"
runat="server">Go to Form 4</mobile:Link>
</mobile:Form>
说明: