自己做了个小控件玩一下,结果实现了IPostBackDataHandler接口所要的方法还是出错
代码如下,已经实现了IPostBackDataHandler所要的方法还是提示必须为IPostBackDataHandler实现xxxx方法,不懂那里出问题了........Imports System
Imports System.Collections.Specialized
Imports System.Text
Imports System.Web
Imports System.Web.UI
Namespace LU.TextBox
Public Class MyTextBox
Inherits System.Web.UI.Control
Implements IPostBackDataHandler
Private _Text As String
Public Property Text() As String
Get
Return _Text
End Get
Set(ByVal value As String)
_Text = value
End Set
End Property
'重写呈现HTML的方法
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim builder As New StringBuilder()
builder.Append("<input type=text name=" & Me.UniqueID & " value=" & HttpUtility.HtmlEncode(Text) & "/>")
writer.Write(builder.ToString())
End Sub
Public Overridable Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As NameValueCollection) As Boolean
Dim oldValue As String = Text
Dim newValue As String = postCollection(Me.UniqueID)
If oldValue Is Nothing Or Not oldValue.Equals(newValue) Then
Text = newValue
Return True
End If
Return False
End Function
Public Overridable Sub RaisePostDataChangedEvent()
OntextChanged(EventArgs.Empty)
End Sub
'申明事件TextChanged并指定与之匹配的委托EventHandler
Public Event TextChanged As EventHandler
Protected Overridable Sub OntextChanged(ByVal e As EventArgs)
'注册事件
AddHandler Me.TextChanged, AddressOf Work
'引发事件
RaiseEvent TextChanged(Me, e)
End Sub
Protected Sub Work(ByVal Send As Object, ByVal e As System.EventArgs)
HttpContext.Current.Response.Write("<script language='javascript'>alert('不要,不要');</script>")
End Sub
End Class
End Namespace --------------------编程问答-------------------- 忘了给分,明天加分 --------------------编程问答-------------------- 问题解决,原来语法和C#不太一样的
补充:.NET技术 , ASP.NET