S
Stanley
I have a WYSISYG server control that I have built. I am having problems
getting the text out of it on post back. I have the code below to handle the
postback. However, when I load the control in my ASPX page and try to do:
Response.Write(myControl.Text)
I get nothing. When debugging I found that the value is there until control
goes back to my ASPX page and it attempts to get the text value. so through
the code below the text is there as it should be. I have been stuck on this
for two day now and can't seem to figure out why it is clearing the value. I
have tried to store the value in a private variable and in the current
context session variable. All get set to nothing. This is a must have item
that I cannot purchase so I have to get this working. Thanks for any help.
Public Event TextChanged As EventHandler
Public Property Text() As String
Get
Return CType(Me.ViewState("Text"), String)
End Get
Set(ByVal Value As String)
Value = Replace(Value, "\", "\") '\ is a Special
Character, Replace with \\
Value = Replace(Value, "'", "’") ' ' is cause of
Error, replace with \'
Value = Replace(Value, vbCrLf, " ")
Value = Replace(Value, """", """)
Me.ViewState("Text") = Value
End Set
End Property
Public Function LoadPostData(ByVal postDataKey As String, ByVal
postCollection As System.Collections.Specialized.NameValueCollection) As
Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData
Dim currentValue As String = Me.Text
Dim postedValue As String = postCollection(postDataKey)
If currentValue Is Nothing Or Not postedValue.Equals(currentValue)
Then
Me.Text = postedValue
Return True
End If
Return False
End Function
Public Sub RaisePostDataChangedEvent() Implements
System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent
OnTextChanged(EventArgs.Empty)
End Sub
Protected Overridable Sub OnTextChanged(ByVal e As EventArgs)
RaiseEvent TextChanged(Me, e)
End Sub
getting the text out of it on post back. I have the code below to handle the
postback. However, when I load the control in my ASPX page and try to do:
Response.Write(myControl.Text)
I get nothing. When debugging I found that the value is there until control
goes back to my ASPX page and it attempts to get the text value. so through
the code below the text is there as it should be. I have been stuck on this
for two day now and can't seem to figure out why it is clearing the value. I
have tried to store the value in a private variable and in the current
context session variable. All get set to nothing. This is a must have item
that I cannot purchase so I have to get this working. Thanks for any help.
Public Event TextChanged As EventHandler
Public Property Text() As String
Get
Return CType(Me.ViewState("Text"), String)
End Get
Set(ByVal Value As String)
Value = Replace(Value, "\", "\") '\ is a Special
Character, Replace with \\
Value = Replace(Value, "'", "’") ' ' is cause of
Error, replace with \'
Value = Replace(Value, vbCrLf, " ")
Value = Replace(Value, """", """)
Me.ViewState("Text") = Value
End Set
End Property
Public Function LoadPostData(ByVal postDataKey As String, ByVal
postCollection As System.Collections.Specialized.NameValueCollection) As
Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData
Dim currentValue As String = Me.Text
Dim postedValue As String = postCollection(postDataKey)
If currentValue Is Nothing Or Not postedValue.Equals(currentValue)
Then
Me.Text = postedValue
Return True
End If
Return False
End Function
Public Sub RaisePostDataChangedEvent() Implements
System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent
OnTextChanged(EventArgs.Empty)
End Sub
Protected Overridable Sub OnTextChanged(ByVal e As EventArgs)
RaiseEvent TextChanged(Me, e)
End Sub