View data loaded by loading LoadPostData in ASP.NET

What is the best way to view the data loaded by LoadPostData into controls in ASP.NET?

0


source to share


3 answers


It's really simple. The nameValueCollection that is passed to this method of EACH control that implements the IPostbackDataHandler interface is the content of the Page.Request.Form. This way you can access it at any time by getting Watch on HttpContext.Current.Request.Form

.



+2


source


Ugh ... I would suggest setting up the IDE to debug the .net framework and set a breakpoint on the LoadPostData () control method. It's a little cumbersome, but if you're willing to go through recursive calls to the Control class (perhaps set a conditional breakpoint on a method?), You can get to the data that way.



Good luck!

+1


source


If you want to be sure to look at the data going into a specific control, you can subclass its control type and break it down during custom implementation IPostBackDataHandler.LoadPostData

.

For example, you have a programmatically added control to collect the user's city. Change:

Public City As Textbox

      

to

Public City As BreakableLoadPostDataTextBox

Public Class BreakableLoadPostDataTextBox
  Inherits TextBox

  Protected Overrides Function LoadPostData( _
    ByVal postDataKey As String, _
    ByVal postCollection As System.Collections.Specialized.NameValueCollection) _
    As Boolean

    Return MyBase.LoadPostData(postDataKey, postCollection) ' Break here
  End Function
End Class

      

Set a breakpoint on the call Return

. When interrupts are executed, you should be able to see postDataKey

which one is being used to read the new control value from postCollection

. You can of course expand this method to your heart with Trace calls and whatnot.

+1


source







All Articles