[英]Setting a design-time property from the properties window of a custom web server control hangs/crashes Visual Studio 2010
[英]How to specify values for a property in the Properties window in Visual Studio 2010
我想做的是創建一個ASP.net用戶控件,該控件具有其他人可以通過Visual Studio 2010中“屬性”窗口更改的屬性。我已經弄清楚了如何使用諸如<System.ComponentModle.DefaultValue(100)>
緊接在“ Public Propery
之前……但是我想要的是屬性窗口中的下拉列表。
例如, <asp:Button>
有一個名為ClientIDMode
的屬性,在Visual Studio 2010中,我可以單擊其在屬性窗口中的下拉菜單,它將顯示不同的選項:“自動ID”,“繼承”,“可預測”和“靜態的”。
如何在自己的用戶控件中創建相同的行為?
您可以為此使用Enum,還有其他方法,但這對您來說是一個很好的開始...
Imports System.ComponentModel
Public Class UserControl1
Public Enum PetSize
Big
Normal
Small
End Enum
Private myPetSize As PetSize
<System.ComponentModel.Description("Select pet size")>
Public Property PetSize() As PetSize
Get
Return myPetSize
End Get
Set(ByVal value As PetSize)
myPetSize = value
End Set
End Property
End Class
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.