HtmlHelper.ListBox 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
ListBox(String, String, IEnumerable<SelectListItem>)
傳回 HTML 清單方塊控制項,此控制項含有指定名稱,並包含指定清單項目和預設項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單方塊的 SelectListItem 實例清單。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, IDictionary<String,Object>)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱、大小、透過屬性字典定義的自訂屬性、項目、預設項目及選取項目,並指定是否已啟用多個選取項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- size
- Int32
要指派給元素 size 屬性的值。
- allowMultiple
- Boolean
true 表示已啟用多個選取專案;否則為 false。
- htmlAttributes
- IDictionary<String,Object>
元素之自訂屬性的名稱和值。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱、大小、項目、預設項目及選取項目,並指定是否已啟用多個選取項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- size
- Int32
要指派給元素 size 屬性的值。
- allowMultiple
- Boolean
true 表示已啟用多個選取專案;否則為 false。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object, Object)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱、項目、預設項目、透過屬性物件定義的自訂屬性,以及選取項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, htmlAttributes As Object) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- htmlAttributes
- Object
包含元素之自訂屬性的物件。 這些屬性 (Attribute) 名稱和值是藉由檢查物件之屬性 (Property),透過反映所擷取而來。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱和透過屬性字典定義的自訂屬性,並包含指定的清單項目、預設項目及選取項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- htmlAttributes
- IDictionary<String,Object>
元素之自訂屬性的名稱和值。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, IEnumerable<SelectListItem>, Object, Int32, Boolean)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱、大小、清單項目及預設的選取項目,並指定是否已啟用多個選取項目。
public System.Web.IHtmlString ListBox (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- size
- Int32
要指派給元素 size 屬性的值。
- allowMultiple
- Boolean
true 表示已啟用多個選取專案;否則為 false。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, IEnumerable<SelectListItem>, Object)
傳回 HTML 清單方塊控制項,此控制項含有指定名稱和透過屬性物件定義的自訂屬性,並包含指定清單項目。
public System.Web.IHtmlString ListBox (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- htmlAttributes
- Object
包含元素之自訂屬性的物件。 這些屬性 (Attribute) 名稱和值是藉由檢查物件之屬性 (Property),透過反映所擷取而來。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱和透過屬性字典定義的自訂屬性,並包含指定的清單項目和預設項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- htmlAttributes
- IDictionary<String,Object>
元素之自訂屬性的名稱和值。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, Object)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱、大小、透過屬性物件定義的自訂屬性、項目、預設項目及選取項目,並指定是否已啟用多個選取項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object selectedValues, int size, bool allowMultiple, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj * int * bool * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), selectedValues As Object, size As Integer, allowMultiple As Boolean, htmlAttributes As Object) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- selectedValues
- Object
用以指定清單中預設選取之項目的物件。 這些選取項目是藉由檢查物件之屬性,透過反映所擷取而來。
- size
- Int32
要指派給元素 size 屬性的值。
- allowMultiple
- Boolean
true 表示已啟用多個選取專案;否則為 false。
- htmlAttributes
- Object
包含元素之自訂屬性的物件。 這些屬性 (Attribute) 名稱和值是藉由檢查物件之屬性 (Property),透過反映所擷取而來。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 null 或空白。
適用於
ListBox(String, IEnumerable<SelectListItem>, IDictionary<String,Object>)
傳回 HTML 清單方塊控制項,此控制項含有指定名稱和透過屬性字典定義的自訂屬性,並包含指定清單項目。
public System.Web.IHtmlString ListBox (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, System.Collections.Generic.IDictionary<string,object> htmlAttributes);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> * System.Collections.Generic.IDictionary<string, obj> -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As IDictionary(Of String, Object)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
- htmlAttributes
- IDictionary<String,Object>
元素之自訂屬性的名稱和值。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 Null 或空白。
適用於
ListBox(String, IEnumerable<SelectListItem>)
傳回 HTML 清單方塊控制項,此控制項含有指定名稱並包含指定清單項目。
public System.Web.IHtmlString ListBox (string name, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList);
member this.ListBox : string * seq<System.Web.WebPages.Html.SelectListItem> -> System.Web.IHtmlString
Public Function ListBox (name As String, selectList As IEnumerable(Of SelectListItem)) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- selectList
- IEnumerable<SelectListItem>
用來填入清單的 SelectListItem 實例清單。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 Null 或空白。
適用於
ListBox(String, String, IEnumerable<SelectListItem>, Object)
傳回 HTML 清單方塊控制項,此控制項含有指定的名稱和透過屬性物件定義的自訂屬性,並包含指定的清單項目和預設項目。
public System.Web.IHtmlString ListBox (string name, string defaultOption, System.Collections.Generic.IEnumerable<System.Web.WebPages.Html.SelectListItem> selectList, object htmlAttributes);
member this.ListBox : string * string * seq<System.Web.WebPages.Html.SelectListItem> * obj -> System.Web.IHtmlString
Public Function ListBox (name As String, defaultOption As String, selectList As IEnumerable(Of SelectListItem), htmlAttributes As Object) As IHtmlString
參數
- name
- String
要指派給 HTML 選取專案之 name 屬性的值。
- defaultOption
- String
要針對清單中預設選項顯示的文字。
- selectList
- IEnumerable<SelectListItem>
用來填入清單方塊的 SelectListItem 實例清單。
- htmlAttributes
- Object
包含元素之自訂屬性的物件。 這些屬性 (Attribute) 名稱和值是藉由檢查物件之屬性 (Property),透過反映所擷取而來。
傳回
代表清單方塊控制項的 HTML 標記。
例外狀況
name
為 Null 或空白。