Thanks for you reply
I've used the code you've send me. It did not work. I made my
control
a
lot
simpeler and the result was the same.
It looked as if the button click event were not handled by te
procedure
of
the addresoff statement:
The code looks now like: (And I'm sure that the createchildcontrols
is
called instaed of the the buttonclick procedure)
Protected Overrides Sub CreateChildControls()
If Me.Page.IsPostBack Then ' this is what runs after the button
click
''Exit Sub '' (if I use Exit sub, no control is displayed)
End If
But = New Button
But.Text = "Submit"
But.ID = ClientID & "X"
Controls.Add(But)
AddHandler But.Click, AddressOf Me.ButtonClick
ChildControlsCreated = True
end Sub
Private Sub ButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
But = FindControl(ClientID & "X")
But.Text = "xxxx"
Controls.Add(But)
End Sub
I've dimensioned the button But as a private control, did not help
íve done this with the withevents keyword, no difference
and i've dimensioned them in the procedures createchildrecords and
buttonclick
no differences
Ton
"Alessandro Zifiglio" <
[email protected]>
schreef
in
bericht ton,
what do you want to do with the caputred event ?
If all you need to do is capture it and take action in your
control
itself
then you can easily do this :
1.In createchildcontrols as you add your control that posts back,
a
button
control for example :
Dim button1 As New Button()
button1.Text = "Submit"
Controls.Add(button1)
'Notice the event handler defined below
AddHandler button1.Click, AddressOf Me.ButtonClicked
now define the buttonclicked sub in your control and take action
there,
everytime the button is clicked this will fire :
Private Sub ButtonClicked(sender As [Object], e As EventArgs)
'What to do when button is clicked
End Sub
Should work for you, however I havent tested, but