M
Magnus Pesch
Sorry,
I thought i would be in an german NG. I will try to translate...
i have made a UserControl (later there should be some controls in it) as
ascx-file (in Visual Studio 2003) and i am loading it in a normal WebForm.
In this UserControl should be properties (and later functions) which should
be changed (called) in the WebForm.
When I open the WebForm anythinf is ok.
But when i want to change the property (when the WebForm is already loaded)
and a PostBack is made, there is no change in the control from the
UserControl.Why? What can i do?
At the bottom there is my coding - there i used the property just for the
Text in a TextBox.
It would be nice, if anyone can help me with this. Maybe i must implement
IPostBackEventHandler...? How does this work?
I thought i would be in an german NG. I will try to translate...
i have made a UserControl (later there should be some controls in it) as
ascx-file (in Visual Studio 2003) and i am loading it in a normal WebForm.
In this UserControl should be properties (and later functions) which should
be changed (called) in the WebForm.
When I open the WebForm anythinf is ok.
But when i want to change the property (when the WebForm is already loaded)
and a PostBack is made, there is no change in the control from the
UserControl.Why? What can i do?
At the bottom there is my coding - there i used the property just for the
Text in a TextBox.
It would be nice, if anyone can help me with this. Maybe i must implement
IPostBackEventHandler...? How does this work?
Greetings from Germany, Magnus
My Coding:
*** CodeBehind UserControl
Public Class TestControl
Inherits System.Web.UI.UserControl
Private Text As String
Public Sub New()
Text = "nicht gesetzt"
End Sub
Public Sub New(ByVal Bezeichnung)
Text = Bezeichnung
End Sub
Public Property Bezeichnung() As String
Return Text
End Get
Set(ByVal Value As String)
Text = Value
End Set
End Property
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
TextBoxControl.Text = Text
End Class
*** Ende UserControl
*** Call in WebForm
Public Class WebForm1
Inherits System.Web.UI.Page
Dim c1 As UserControl = LoadControl("TestControl.ascx")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim c1 as UserControl = LoadControl("TestControl.ascx")
CType(c1, TestControl).Bezeichnung = "jetzt Text definiert"
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
CType(c1, TestControl).Bezeichnung = "Text geändert"