all groups > asp.net building controls > january 2004 >
You're in the

asp.net building controls

group:

How can I use events within the server control


How can I use events within the server control ton
1/28/2004 7:10:29 PM
asp.net building controls:
Hi,
I wrote a customserver control with 2 columns showing the data from 1
record.
i use label & hyperlink as for the field name and text and checkboxes for
the other data.

I want to use the hyperlink. How can I get a postback on that hyperlink.

Ton

Re: How can I use events within the server control Alessandro Zifiglio
1/29/2004 6:55:20 PM
hyperlink control does not postback. Use a linkbutton control instead.

As an alternative you can always define an anchor element and have it raise
a postback event but then the end product is a link button
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpostbackusingjavascriptsample.asp

so in short, if you are building a composite control use a linkbutton
control ;P

[quoted text, click to view]

Re: How can I use events within the server control ton
1/29/2004 8:45:38 PM
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" <alessandrozifiglio@NO-SPAM-hotmail.com> schreef in
bericht news:zTbSb.1276$HO2.977@news.edisontel.com...
[quoted text, click to view]

AddThis Social Bookmark Button