统计在线人数...

ASP.NET 移动控件--Label 控件

[ 来源:转载 | 作者:佚名 | 时间:2006-5-29 下午 12:23:41 | 浏览:统计中... ]

建基于文本的控件,该控件在移动设备上显示只可输出的文本。可以通过使用 Text 属性或作为 <Label> 元素的内容指定标签的文本。如果用两种方式指定 Text 属性,则内部文本始终优先。但是,如果以编程方式设置 Text 属性,则会自动移除内部文本,新设置的属性优先。

移动控件语法
必需的属性、默认值和具有代码特征的元素以粗体显示。

<mobile:Label
   runat="server"
   id="id"
   Font-Name="fontName"
   Font-Size="{NotSet|Normal|Small|Large}"
   Font-Bold="{NotSet|False|True}"
   Font-Italic="{NotSet|False|True}"
   ForeColor="foregroundColor"
   BackColor="backgroundColor"
   Alignment="{NotSet|Left|Center|Right}"
   StyleReference="styleReference"
   Text="Text"
   Wrapping="{NotSet|Wrap|NoWrap}">
innerText
</mobile:Label>
包容规则
从 TextControl 类派生的所有具体类的包容规则是相同的。以下控件可以包含 Label 控件。

控件 说明 
System.Web.UI.MobileControls.Form 可以包含任意多个 Label 控件。 
System.Web.UI.MobileControls.Panel 可以包含任意多个 Label 控件。 

Label 控件不能包含任何其他控件。

设备模板
无。

特定于设备的行为
标签呈现的样式将根据设备的不同而有所不同,但标签文本将显示在所有设备上。在 HTML 和 WML 中,标签呈现方式相同。

控件在其自己的行上呈现标签的文本,并应用适当的样式属性。标签后面有一个 <br> 标记(分行符)。在窗体上,如果您在一个标签后面添加另一个标签,则分行符将导致标签呈现在垂直的列上。

有关不同的设备如何解释不同样式属性的更多信息,请参见特定于设备的呈现文档。

示例
下面的示例使用两个标签,每个 Form 控件上一个。第一个标签未经修改,因此不需要 ID 属性。第二个标签的值的 ID 属性为 WelcomeMessage,Button_OnClick 事件处理程序激活其窗体。

[Visual Basic]
<%@ Page Inherits=
   "System.Web.UI.MobileControls.MobilePage" Language="VB" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<script language="vb" runat="server">
protected Sub Submit_Click(sender as Object, e as EventArgs) 
   WelcomeMessage.Text = "Welcome to my app, " + NameEdit.Text
   ActiveForm = Form2
End Sub
</script>

<mobile:Form runat="server">
  <mobile:Label runat="server">Enter your name</mobile:Label>
  <mobile:TextBox runat="server" id="NameEdit" />
  <mobile:Command runat="server" id="Submit" OnClick="Submit_Click">
      OK
  </mobile:Command>
</mobile:Form>

<mobile:Form runat="server" id="Form2">
  <mobile:Label runat="server" id="WelcomeMessage" />
</mobile:Form>
[C#]
<%@ Page Inherits=
   "System.Web.UI.MobileControls.MobilePage" Language="C#" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<script language="c#" runat="server">
protected void Submit_Click(Object sender, EventArgs e) 
{
   WelcomeMessage.Text = "Welcome to my app, " + NameEdit.Text;
   ActiveForm = Form2;
}
</script>

<mobile:Form runat="server">
  <mobile:Label runat="server">Enter your name</mobile:Label>
  <mobile:TextBox runat="server" id="NameEdit" />
  <mobile:Command runat="server" id="Submit" OnClick="Submit_Click">
      OK
  </mobile:Command>
</mobile:Form>

<mobile:Form runat="server" id="Form2">
  <mobile:Label runat="server" id="WelcomeMessage" />
</mobile:Form>

共有0人参与评价,平均得分:0分
评论内容只代表网友观点,与本站立场无关! 查看完整内容
   

当前在线人数
QQ:748838 MSN:allen_xia#msn.com E-mail:allenxia666#126.com QQ群:站长联盟北方区-北京(28200145) 站长联盟南方区-上海(67713522)