Solved: AspNetWrapper

Answered
0
0

Hi!

I’m testing AspNetWrapper, but I have a question: how can I execute a method directly?

Please, see the attachment.

Thanks,
Ulisses.

Attachment
  • You must to post comments
Best Answer
0
0

Hi Ulisses,

it can´t be done that way because ASP.NET controls do not exist outside of the postback request.
Saving the reference to the ASP.NET control does not work with ASP.NET as controls can only be used during the page cycle:
https://msdn.microsoft.com/en-us/library/ms178472.aspx

So basically any change to an ASP-NET control can only be applied while processing Init, Load etc.

The code below works.

Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports Wisej.Web.Ext.AspNetControl

<ToolboxItem(True)>
Public Class clsListbox
Inherits AspNetWrapper(Of UI.WebControls.ListBox)

Public Sub New()
Me.ScrollBars = False
End Sub

Public ReadOnly Property Items As ListItemCollection

Get
Return _items
End Get

End Property

Dim _items As New System.Web.UI.WebControls.ListItemCollection

Private Sub clsListbox_Init(sender As Object, e As EventArgs) Handles Me.Init

For Each Item In Me.Items
Me.WrappedControl.Items.Add(Item)
Next

End Sub

End Class

 

Hope that helps.

Best regards
Frank

  • Ulisses
    Thanks a lot!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.