ObjectList.CommandStyle 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
개체 목록 명령에 사용되는 스타일을 가져오거나 설정합니다. 이 API는 더 이상 사용되지 않습니다. ASP.NET 모바일 애플리케이션을 개발하는 방법에 대한 자세한 내용은 ASP.NET 있는 Mobile Apps & 사이트를 참조하세요.
public:
property System::Web::UI::MobileControls::Style ^ CommandStyle { System::Web::UI::MobileControls::Style ^ get(); void set(System::Web::UI::MobileControls::Style ^ value); };
public System.Web.UI.MobileControls.Style CommandStyle { get; set; }
member this.CommandStyle : System.Web.UI.MobileControls.Style with get, set
Public Property CommandStyle As Style
속성 값
개체 목록 명령에 사용되는 스타일입니다.
예제
다음 코드 예제에서는 사용 하는 방법을 CommandStyle 의 스타일을 설정 하는 속성을 ObjectList 선언적를 사용 하 여 DeviceSpecific 섹션에서 지정한 CommandStyle 다양 한 디바이스에 대 한 설정을 합니다.
참고
다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. 자세한 내용은 ASP.NET Web Forms 페이지 코드 모델합니다.
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
int bakeryCount = 0, dairyCount = 0, produceCount = 0;
public void Page_Load(Object o, EventArgs e)
{
if (!IsPostBack)
{ // Create an array and bind it to the list
ArrayList arr = new ArrayList();
arr.Add (new GroceryItem
("Bakery", "Rolls", "On Sale"));
arr.Add (new GroceryItem
("Dairy", "Eggnog", "Half price"));
arr.Add (new GroceryItem
("Produce", "Apples",
"A dollar a bushel"));
arr.Add (new GroceryItem
("Bakery", "Bread", "On Sale"));
List1.DataSource = arr;
List1.DataBind ();
// To show only one field on opening page,
// comment the next line
List1.TableFields = "Item;Department";
List1.LabelField = "Department";
// Display a report after items are databound
string txt = "Number of items by Department<br>Produce: {0}<br />" +
"Dairy: {1}<br />Bakery: {2}";
TextView2.Text = String.Format(txt, produceCount, dairyCount, bakeryCount);
}
}
// Command event for buttons
public void List1_Click(Object sender,
ObjectListCommandEventArgs e)
{
if (e.CommandName == "Reserve")
ActiveForm = Form2;
else if (e.CommandName == "Buy")
ActiveForm = Form3;
else
ActiveForm = Form4;
}
//<Snippet4>
// Count items in each department
private void List1_ItemDataBind(object sender, ObjectListDataBindEventArgs e)
{
switch (((GroceryItem)e.DataItem).Department)
{
case "Bakery":
bakeryCount++;
break;
case "Dairy":
dairyCount++;
break;
case "Produce":
produceCount++;
break;
}
}
//</Snippet4>
//<Snippet2>
private void AllFields_Click(object sender, EventArgs e)
{
ActiveForm = Form5;
string spec = "{0}: {1}<br/>";
IObjectListFieldCollection flds = List1.AllFields;
for (int i = 0; i < flds.Count; i++)
TextView1.Text +=
String.Format(spec, (i + 1), flds[i].Title);
}
//</Snippet2>
// Structure for ArrayList records
private class GroceryItem
{ // A private class for the Grocery List
private String _department, _item, _status;
public GroceryItem(string department,
string item, string status)
{
_department = department;
_item = item;
_status = status;
}
public String Department
{ get { return _department; } }
public String Item
{ get { return _item; } }
public String Status
{ get { return _status; } }
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form id="Form1" runat="server" BackColor="LightBlue">
<mobile:ObjectList id="List1" runat="server"
OnItemCommand="List1_Click" OnItemDataBind="List1_ItemDataBind">
<DeviceSpecific ID="DeviceSpecific1" Runat="server">
<!-- See Web.config for filters -->
<Choice Filter="isWML11" CommandStyle-Font-Bold="NotSet" />
<Choice CommandStyle-Font-Bold="true"
CommandStyle-Font-Name="Arial" />
</DeviceSpecific>
<Command Name="Reserve" Text="Reserve" />
<Command Name="Buy" Text="Buy" />
</mobile:ObjectList>
<mobile:Command ID="AllFieldsCmd" Runat="server"
OnClick="AllFields_Click">
List All Fields</mobile:Command>
<mobile:TextView ID="TextView2" Runat="server" />
</mobile:Form>
<mobile:Form id="Form2" runat="server" BackColor="LightBlue">
<mobile:Label id="ResLabel" runat="server"
text="Sale item reservation system coming soon!" />
<mobile:Link id="ResLink" NavigateURL="#Form1"
runat="server" text="Return" />
</mobile:Form>
<mobile:Form id="Form3" runat="server" BackColor="LightBlue">
<mobile:Label id="BuyLabel" runat="server"
Text="Online purchasing system coming soon!" />
<mobile:Link ID="BuyLink" NavigateURL="#Form1"
Runat="server" text="Return" />
</mobile:Form>
<mobile:Form id="Form4" Runat="server" BackColor="LightBlue">
<mobile:Label ID="DefLabel" Runat="server"
Text="Detailed item descriptions will be here soon!"/>
<mobile:Link ID="DefLink" NavigateURL="#Form1"
Runat="server" Text="Return" />
</mobile:Form>
<mobile:Form ID="Form5" Runat="server">
<mobile:Label Runat="server">
List of AllFields:</mobile:Label>
<mobile:TextView ID="TextView1" Runat="server" />
<mobile:Link Runat="server" NavigateUrl="#Form1"
Text="Return"></mobile:Link>
</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" %>
<script runat="server">
Dim bakeryCount, dairyCount, produceCount As Integer
Private Sub Page_Load(ByVal o As Object, ByVal e As EventArgs)
If Not IsPostBack Then
' Create an array and bind it to the list
Dim arr As New ArrayList()
arr.Add(New GroceryItem _
("Bakery", "Rolls", "On Sale"))
arr.Add(New GroceryItem _
("Dairy", "Eggnog", "Half price"))
arr.Add(New GroceryItem _
("Produce", "Apples", _
"A dollar a bushel"))
arr.Add(New GroceryItem _
("Bakery", "Bread", "On Sale"))
List1.DataSource = arr
List1.DataBind()
' To show only one field on opening page,
' comment the next line
List1.TableFields = "Item;Department"
List1.LabelField = "Department"
' Display a report after items are databound
Const txt As String = "Number of items by Department<br>Produce: " + _
"{0}<br />Dairy: {1}<br />Bakery: {2}"
TextView2.Text = String.Format(txt, produceCount, dairyCount, bakeryCount)
End If
End Sub
' Command event for buttons
Private Sub List1_Click(ByVal sender As Object, _
ByVal e As ObjectListCommandEventArgs)
If e.CommandName = "Reserve" Then
ActiveForm = Form2
ElseIf e.CommandName = "Buy" Then
ActiveForm = Form3
Else
ActiveForm = Form4
End If
End Sub
'<Snippet4>
' Count items in each department
Private Sub List1_ItemDataBind(ByVal sender As Object, ByVal e As ObjectListDataBindEventArgs)
Select Case CType(e.DataItem, GroceryItem).Department
Case "Bakery"
bakeryCount += 1
Case "Dairy"
dairyCount += 1
Case "Produce"
produceCount += 1
End Select
End Sub
'</Snippet4>
'<Snippet2>
Private Sub AllFields_Click(ByVal sender As Object, ByVal e As EventArgs)
ActiveForm = Form5
Dim spec As String = "{0}: {1}<br/>"
Dim flds As IObjectListFieldCollection = List1.AllFields
Dim i As Integer
For i = 0 To flds.Count - 1
TextView1.Text += _
String.Format(spec, (i + 1), flds(i).Title)
Next
End Sub
'</Snippet2>
' Structure for ArrayList records
Private Class GroceryItem
' A private class for the Grocery List
Private _department, _item, _status As String
Public Sub New(ByVal department As String, _
ByVal item As String, ByVal status As String)
_department = department
_item = item
_status = status
End Sub
Public ReadOnly Property Department() As String
Get
Return _department
End Get
End Property
Public ReadOnly Property Item() As String
Get
Return _item
End Get
End Property
Public ReadOnly Property Status() As String
Get
Return _status
End Get
End Property
End Class
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form id="Form1" runat="server" BackColor="LightBlue">
<mobile:ObjectList id="List1" runat="server"
OnItemCommand="List1_Click" OnItemDataBind="List1_ItemDataBind">
<DeviceSpecific ID="DeviceSpecific1" Runat="server">
<!-- See Web.config for filters -->
<Choice Filter="isWML11" CommandStyle-Font-Bold="NotSet" />
<Choice CommandStyle-Font-Bold="true"
CommandStyle-Font-Name="Arial" />
</DeviceSpecific>
<Command Name="Reserve" Text="Reserve" />
<Command Name="Buy" Text="Buy" />
</mobile:ObjectList>
<mobile:Command ID="AllFieldsCmd" Runat="server"
OnClick="AllFields_Click">
List All Fields</mobile:Command>
<mobile:TextView ID="TextView2" Runat="server" />
</mobile:Form>
<mobile:Form id="Form2" runat="server" BackColor="LightBlue">
<mobile:Label id="ResLabel" runat="server"
text="Sale item reservation system coming soon!" />
<mobile:Link id="ResLink" NavigateURL="#Form1"
runat="server" text="Return" />
</mobile:Form>
<mobile:Form id="Form3" runat="server" BackColor="LightBlue">
<mobile:Label id="BuyLabel" runat="server"
Text="Online purchasing system coming soon!" />
<mobile:Link ID="BuyLink" NavigateURL="#Form1"
Runat="server" text="Return" />
</mobile:Form>
<mobile:Form id="Form4" Runat="server" BackColor="LightBlue">
<mobile:Label ID="DefLabel" Runat="server"
Text="Detailed item descriptions will be here soon!"/>
<mobile:Link ID="DefLink" NavigateURL="#Form1"
Runat="server" Text="Return" />
</mobile:Form>
<mobile:Form ID="Form5" Runat="server">
<mobile:Label ID="Label1" Runat="server">
List of AllFields:</mobile:Label>
<mobile:TextView ID="TextView1" Runat="server" />
<mobile:Link ID="Link1" Runat="server" NavigateUrl="#Form1"
Text="Return"></mobile:Link>
</mobile:Form>
</body>
</html>
여러 디바이스 특정 필터를 사용 하 여 샘플 Web.config 파일입니다.
설명
이 속성이 프로그래밍 방식으로 설정된 경우 각 요청에 대해 속성이 동적으로 설정되지 않는 한 유지되지 않습니다. 경우는 속성 선언적으로 설정 됩니다 속성은 각 요청에 설정 됩니다. 기본값은 없습니다.
이후 다른 디바이스에는 스타일에 대 한 다른 요구 사항이 있습니다. 속성에 대한 CommandStyle 몇 가지 DeviceSpecific 설정을 원할 수 있습니다.
적용 대상
추가 정보
.NET