本文整理汇总了VB.NET中System.Web.UI.IAttributeAccessor接口的典型用法代码示例。如果您正苦于以下问题:VB.NET IAttributeAccessor接口的具体用法?VB.NET IAttributeAccessor怎么用?VB.NET IAttributeAccessor使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
在下文中一共展示了IAttributeAccessor接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: SetAttribute
' The following class creates a custom ASP.NET server control that implements
' the IAttributeAccessor interface. It creates a MyTextBox class that contains
' Width and Text properties that get and set their values from view state.
' Pages that use this control create an instance of this control and set the
' Width property using the IAttributeAccessor.SetAttribute method.
' The page then displays the values of the Text and Width properties
' using the IAttributeAccessor.GetAttribute method.
' When compiled, this assembly is named MyAttributeAccessor.
Imports System.Web
Imports System.Web.UI
Imports System.Security.Permissions
Namespace AttributeAccessor
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class MyTextBox
Inherits Control
Implements IAttributeAccessor
' Declare the Width property.
Public Property Width() As String
Get
Return CType(ViewState("Width"), String)
End Get
Set
ViewState("Width") = value
End Set
End Property
' Declare the Text property.
Public Property Text() As String
Get
Return CType(ViewState("Text"), String)
End Get
Set
ViewState("Text") = value
End Set
End Property
' Implement the SetAttribute method for the control. When
' this method is called from a page, the control's properties
' are set to values defined in the page.
Public Sub SetAttribute(name As String, value1 As String) Implements IAttributeAccessor.SetAttribute
ViewState(name) = value1
End Sub
' Implement the GetAttribute method for the control. When
' this method is called from a page, the values for the control's
' properties can be displayed in the page.
Public Function GetAttribute(name As String) As String Implements IAttributeAccessor.GetAttribute
Return CType(ViewState(name), String)
End Function 'GetAttribute
Protected Overrides Sub Render(output As HtmlTextWriter)
output.Write(("<input type=text id= " + Me.UniqueID))
output.Write((" Value='" + Me.Text))
output.Write(("' Size=" + Me.Width + ">"))
End Sub
End Class
End Namespace 'AttributeAccessor
开发者ID:VB.NET开发者,项目名称:System.Web.UI,代码行数:62,代码来源:IAttributeAccessor
注:本文中的System.Web.UI.IAttributeAccessor接口示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论