xpblueScreenOfDeath
Programmer
- Sep 1, 2004
- 87
I can't figure out why LoadPostData is not firing. What am I doing wrong and how to fix it? When I force LoadPostData to fire by calling RegisterRequiresPostBack, but for some reason the values is blank even though I typed in a value before the postback.
heres the output for the response.write in the OnPreRender when I force it to fire:
<Code>
LoadPostData
WebCustomControl11
</Code>
here is what got render for the control:
<Code>
<span id="WebCustomControl11"><input name="WebCustomControl11:dataArr" id="WebCustomControl11_dataArr" type="text" /></span>
</Code>
heres the code:
<Code>
Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer, IPostBackDataHandler
Dim text As System.Web.UI.HtmlControls.HtmlInputText
Protected Overrides Sub CreateChildControls()
text = New System.Web.UI.HtmlControls.HtmlInputText
text.ID = "dataArr"
Controls.Add(text)
End Sub
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If Not (Page Is Nothing) Then
Page.RegisterRequiresPostBack(Me)
End If
End Sub
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
MyBase.Render(output)
End Sub
Public Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As System.Collections.Specialized.NameValueCollection) As Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData
Dim value = postCollection(postDataKey)
Page.Response.Write("LoadPostData<BR>")
Page.Response.Write(postDataKey & "<BR>")
Page.Response.Write(value & "<BR>")
If Not (text Is Nothing) And text.Value <> value Then
text.Value = value
End If
End Function
Public Sub RaisePostDataChangedEvent() Implements System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent
End Sub
End Class
</Code>
heres the output for the response.write in the OnPreRender when I force it to fire:
<Code>
LoadPostData
WebCustomControl11
</Code>
here is what got render for the control:
<Code>
<span id="WebCustomControl11"><input name="WebCustomControl11:dataArr" id="WebCustomControl11_dataArr" type="text" /></span>
</Code>
heres the code:
<Code>
Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer, IPostBackDataHandler
Dim text As System.Web.UI.HtmlControls.HtmlInputText
Protected Overrides Sub CreateChildControls()
text = New System.Web.UI.HtmlControls.HtmlInputText
text.ID = "dataArr"
Controls.Add(text)
End Sub
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If Not (Page Is Nothing) Then
Page.RegisterRequiresPostBack(Me)
End If
End Sub
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
MyBase.Render(output)
End Sub
Public Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As System.Collections.Specialized.NameValueCollection) As Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData
Dim value = postCollection(postDataKey)
Page.Response.Write("LoadPostData<BR>")
Page.Response.Write(postDataKey & "<BR>")
Page.Response.Write(value & "<BR>")
If Not (text Is Nothing) And text.Value <> value Then
text.Value = value
End If
End Function
Public Sub RaisePostDataChangedEvent() Implements System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent
End Sub
End Class
</Code>