D
David
Hello
I have made a component (MyWebForm) that inherits Page. This component
have a method called 'ComponentAdded' that shows a msgbox if it is in
design mode:
Public Class MyWebForm
Inherits System.Web.UI.Page
Public Sub ComponentAdded()
If ((Not Me.Site Is Nothing) AndAlso (Me.Site.DesignMode)) Then
MsgBox("Method ComponentAdded")
End If
End Sub
End Class
I have another component (MyCotrol) that inherits WebControl, that
execute ComponentAdded method when it is added in MyWebForm in design
mode:
<Designer(GetType(DesignerMyCotrol)), ToolboxData("<{0}:MyCotrol
runat=server></{0}:MyCotrol>")> _
Public Class MyCotrol
Inherits WebControl
End Class
Public Class DesignerMyCobtrol
Inherits System.Web.UI.Design.ControlDesigner
Private control As IurisTextBox
Public Overrides Sub OnSetParent()
Try
control = CType(MyBase.Component, MyControl)
If (control.Page.GetType().Name = "MyWebForm") Then
CType(control.Page, MyWebForm).ComponentAdded()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Overrides Function GetDesignTimeHtml() As String
Return "My Control"
End Function
End Class
I want that when MyControl is added in MyWebForm, excute the
ComponentAdded method.
This code not works very well. When MyControl is added, ComponentAdded
method show an exception saying that some object has not been
inicialized.
But if I save the aspx, close it, and open again, the ComponentAdded
method show the msgbox well.
I think that OnSetParent is not the right method to put this code, but
I haven't find any other. Is there any event that execute when a
control is added in a webform?
Thanks
David
I have made a component (MyWebForm) that inherits Page. This component
have a method called 'ComponentAdded' that shows a msgbox if it is in
design mode:
Public Class MyWebForm
Inherits System.Web.UI.Page
Public Sub ComponentAdded()
If ((Not Me.Site Is Nothing) AndAlso (Me.Site.DesignMode)) Then
MsgBox("Method ComponentAdded")
End If
End Sub
End Class
I have another component (MyCotrol) that inherits WebControl, that
execute ComponentAdded method when it is added in MyWebForm in design
mode:
<Designer(GetType(DesignerMyCotrol)), ToolboxData("<{0}:MyCotrol
runat=server></{0}:MyCotrol>")> _
Public Class MyCotrol
Inherits WebControl
End Class
Public Class DesignerMyCobtrol
Inherits System.Web.UI.Design.ControlDesigner
Private control As IurisTextBox
Public Overrides Sub OnSetParent()
Try
control = CType(MyBase.Component, MyControl)
If (control.Page.GetType().Name = "MyWebForm") Then
CType(control.Page, MyWebForm).ComponentAdded()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Overrides Function GetDesignTimeHtml() As String
Return "My Control"
End Function
End Class
I want that when MyControl is added in MyWebForm, excute the
ComponentAdded method.
This code not works very well. When MyControl is added, ComponentAdded
method show an exception saying that some object has not been
inicialized.
But if I save the aspx, close it, and open again, the ComponentAdded
method show the msgbox well.
I think that OnSetParent is not the right method to put this code, but
I haven't find any other. Is there any event that execute when a
control is added in a webform?
Thanks
David