Control | Conditional custom control to raise the LoadPostData method, you need to include a control with an ID of This.uniqueid
You can add a hidden control to the group of controls!
Writer. Write ("<input type= ' hidden ' name= '" + Me. UniqueID + "' >")
Or simply a simpler approach, set the name attribute of the submit to me. UniqueID
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
<defaultproperty ("Text"), ToolBoxData ("<{0}:login runat=server></{0}:login>") > Public Class Login
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackDataHandler
Public Event CheckError as EventHandler
Private _user as String
Private _pass as String
Public Function LoadPostData (ByVal postdatakey as String, ByVal postcollection as System.Collections.Specialized.NameValueCollection) as Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData
_user = CType (postcollection (Me.uniqueid & ": User"), String)
_pass = CType (postcollection (Me.uniqueid & ":P ass"), String)
If _user <> _pass Then
Return True
Else
Return False
End If
End Function
Public Sub raisepostdatachangedevent () Implements System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent
Oncheckerror ()
End Sub
Public Sub Oncheckerror ()
RaiseEvent CheckError (Me, New System.EventArgs ())
End Sub
Protected Overrides Sub Render (ByVal writer as System.Web.UI.HtmlTextWriter)
Writer. RenderBeginTag (htmltextwritertag.table)
Writer. RenderBeginTag (htmltextwritertag.tr)
Writer. RenderBeginTag (HTMLTEXTWRITERTAG.TD)
Writer. Write ("User name:")
Writer. RenderEndTag ()
Writer. RenderBeginTag (HTMLTEXTWRITERTAG.TD)
Writer. AddAttribute (Htmltextwriterattribute.type, "TextBox")
Writer. AddAttribute (Htmltextwriterattribute.name, Me.uniqueid & ": User")
Writer. AddAttribute (Htmltextwriterattribute.maxlength, "30")
Writer. RenderBeginTag (Htmltextwritertag.input)
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderBeginTag (htmltextwritertag.tr)
Writer. RenderBeginTag (HTMLTEXTWRITERTAG.TD)
Writer. Write ("Password:")
Writer. RenderEndTag ()
Writer. RenderBeginTag (HTMLTEXTWRITERTAG.TD)
Writer. AddAttribute (Htmltextwriterattribute.type, "Password")
Writer. AddAttribute (Htmltextwriterattribute.name, Me.uniqueid & ":P ass")
Writer. AddAttribute (Htmltextwriterattribute.maxlength, "30")
Writer. RenderBeginTag (Htmltextwritertag.input)
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderBeginTag (htmltextwritertag.tr)
Writer. AddAttribute (Htmltextwriterattribute.cols, "2")
Writer. RenderBeginTag (HTMLTEXTWRITERTAG.TD)
Writer. AddAttribute (Htmltextwriterattribute.type, "Submit")
Writer. AddAttribute (Htmltextwriterattribute.name, Me.uniqueid)
Writer. AddAttribute (Htmltextwriterattribute.value, "submit")
Writer. RenderBeginTag (Htmltextwritertag.input)
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderEndTag ()
Writer. RenderEndTag ()
End Sub
End Class