Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > How to add postback function in Custom Server Controls

Reply
Thread Tools

How to add postback function in Custom Server Controls

 
 
ton
Guest
Posts: n/a
 
      01-29-2004
In the procedure CreateChildControls I add several controls like check and
textboxes, button link and so on. How can I get the postback respons on the
button link:
The functions:
lblButtonLink_Command and lblButtonLink_Click will not be executed

Please help

Ton



 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-29-2004
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 theorically this is all
you need if this is your requirement. This is useful if you need to take
action without exposing the event to the container page, giving the
consumers of your control no control, as this event is not exposed to them.

for a complete example that digs deeper into this you might want to look at
the following link :
http://msdn.microsoft.com/library/de...trolsample.asp


Instead if you need to expose this event to the page where your control
sits, and exposed to the end users of your control then you will need to
bubble it up .
Here is a very nice example of how this can be done for composite controls
on MSDN.
http://msdn.microsoft.com/library/de...trolsample.asp

"ton" <(E-Mail Removed)> wrote in message
news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> In the procedure CreateChildControls I add several controls like check and
> textboxes, button link and so on. How can I get the postback respons on

the
> button link:
> The functions:
> lblButtonLink_Command and lblButtonLink_Click will not be executed
>
> Please help
>
> Ton
>
>
>



 
Reply With Quote
 
 
 
 
ton
Guest
Posts: n/a
 
      01-29-2004
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" <(E-Mail Removed)> schreef in
bericht news:9DbSb.1271$(E-Mail Removed)...
> 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 theorically this is all
> you need if this is your requirement. This is useful if you need to take
> action without exposing the event to the container page, giving the
> consumers of your control no control, as this event is not exposed to

them.
>
> for a complete example that digs deeper into this you might want to look

at
> the following link :
>

http://msdn.microsoft.com/library/de...trolsample.asp
>
>
> Instead if you need to expose this event to the page where your control
> sits, and exposed to the end users of your control then you will need to
> bubble it up .
> Here is a very nice example of how this can be done for composite controls
> on MSDN.
>

http://msdn.microsoft.com/library/de...trolsample.asp
>
> "ton" <(E-Mail Removed)> wrote in message
> news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > In the procedure CreateChildControls I add several controls like check

and
> > textboxes, button link and so on. How can I get the postback respons on

> the
> > button link:
> > The functions:
> > lblButtonLink_Command and lblButtonLink_Click will not be executed
> >
> > Please help
> >
> > Ton
> >
> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-29-2004
Should fire. It works for me. However i have noticed that you are trying to
add controls in your button click. This will not work for you because during
postback those controls wont be recreated. so set a flag in viewstate as you
add the control.
Also I have noticed that you are trying to retrieve the same button, the one
that fired the event in its event click and add it to the controls
collection. This is not what what you need to do, but simply have the same
code run after postback. Whatever code you have in your createchildcontrols
method will run after postback, so let it all run as is and remove the
ispostback check in there --If that code is not run your event will never
fire, this is because the viewstate of the control is restored when the
control is reloaded into its container.

Private Sub ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim MyButton As New Button()
MyButton = CType(sender, Button)
context.response.write("Click event for " & MyButton.id & "Fired")
End Sub

http://samples.gotdotnet.com/quickst...ion2.vb&font=3

This is another example :
http://samples.gotdotnet.com/quickst...ion3.vb&font=3


"ton" <(E-Mail Removed)> wrote in message
news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> 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" <(E-Mail Removed)> schreef in
> bericht news:9DbSb.1271$(E-Mail Removed)...
> > 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 theorically this is

all
> > you need if this is your requirement. This is useful if you need to take
> > action without exposing the event to the container page, giving the
> > consumers of your control no control, as this event is not exposed to

> them.
> >
> > for a complete example that digs deeper into this you might want to look

> at
> > the following link :
> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> >
> >
> > Instead if you need to expose this event to the page where your control
> > sits, and exposed to the end users of your control then you will need to
> > bubble it up .
> > Here is a very nice example of how this can be done for composite

controls
> > on MSDN.
> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> >
> > "ton" <(E-Mail Removed)> wrote in message
> > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > In the procedure CreateChildControls I add several controls like check

> and
> > > textboxes, button link and so on. How can I get the postback respons

on
> > the
> > > button link:
> > > The functions:
> > > lblButtonLink_Command and lblButtonLink_Click will not be executed
> > >
> > > Please help
> > >
> > > Ton
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-30-2004
ton, Look at the post "No events are fired in child controls". Jeffery has
just pointed out how useful Implementing the InamingContainer interface
really is, especially when you need events in child controls routed. This is
why your events werent firing.

Iimplement this interface, and do not try passing an explicit id to your
control if you dont need it.

At the moment i myself am having problems passing an explict id to child
controls and i'm working on a workaround. Will postback when I do find a
way. One good reason to want to pass an explicit id is when using a
validator control and as you already know you need to pass your controls id
to its "controlToValidate" property.

If this is not your case then i dont see why it is important to pass an
explicit ID

"Alessandro Zifiglio" <(E-Mail Removed)> wrote in
message news:ZeeSb.1334$(E-Mail Removed)...
> Should fire. It works for me. However i have noticed that you are trying

to
> add controls in your button click. This will not work for you because

during
> postback those controls wont be recreated. so set a flag in viewstate as

you
> add the control.
> Also I have noticed that you are trying to retrieve the same button, the

one
> that fired the event in its event click and add it to the controls
> collection. This is not what what you need to do, but simply have the same
> code run after postback. Whatever code you have in your

createchildcontrols
> method will run after postback, so let it all run as is and remove the
> ispostback check in there --If that code is not run your event will never
> fire, this is because the viewstate of the control is restored when the
> control is reloaded into its container.
>
> Private Sub ButtonClick(ByVal sender As Object, ByVal e As

System.EventArgs)
> Dim MyButton As New Button()
> MyButton = CType(sender, Button)
> context.response.write("Click event for " & MyButton.id & "Fired")
> End Sub
>
>

http://samples.gotdotnet.com/quickst...ion2.vb&font=3
>
> This is another example :
>

http://samples.gotdotnet.com/quickst...ion3.vb&font=3
>
>
> "ton" <(E-Mail Removed)> wrote in message
> news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > 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" <(E-Mail Removed)> schreef

in
> > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > 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 theorically this is

> all
> > > you need if this is your requirement. This is useful if you need to

take
> > > action without exposing the event to the container page, giving the
> > > consumers of your control no control, as this event is not exposed to

> > them.
> > >
> > > for a complete example that digs deeper into this you might want to

look
> > at
> > > the following link :
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > >
> > >
> > > Instead if you need to expose this event to the page where your

control
> > > sits, and exposed to the end users of your control then you will need

to
> > > bubble it up .
> > > Here is a very nice example of how this can be done for composite

> controls
> > > on MSDN.
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > >
> > > "ton" <(E-Mail Removed)> wrote in message
> > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > In the procedure CreateChildControls I add several controls like

check
> > and
> > > > textboxes, button link and so on. How can I get the postback respons

> on
> > > the
> > > > button link:
> > > > The functions:
> > > > lblButtonLink_Command and lblButtonLink_Click will not be executed
> > > >
> > > > Please help
> > > >
> > > > Ton
> > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-30-2004
oops, no workaround. That InamingContainer Interface had me a little
confused ;P
Since this interface already makes control ids unique you just need to pass
your id as is like

button1.id = "button1"
textbox1.id = "textbox1"
and so forth.
When trying to reference textbox1 for example just simply use its id
"Alessandro Zifiglio" <(E-Mail Removed)> wrote in
message news:cmpSb.1494$(E-Mail Removed)...
> ton, Look at the post "No events are fired in child controls". Jeffery has
> just pointed out how useful Implementing the InamingContainer interface
> really is, especially when you need events in child controls routed. This

is
> why your events werent firing.
>
> Iimplement this interface, and do not try passing an explicit id to your
> control if you dont need it.
>
> At the moment i myself am having problems passing an explict id to child
> controls and i'm working on a workaround. Will postback when I do find a
> way. One good reason to want to pass an explicit id is when using a
> validator control and as you already know you need to pass your controls

id
> to its "controlToValidate" property.
>
> If this is not your case then i dont see why it is important to pass an
> explicit ID
>
> "Alessandro Zifiglio" <(E-Mail Removed)> wrote in
> message news:ZeeSb.1334$(E-Mail Removed)...
> > Should fire. It works for me. However i have noticed that you are trying

> to
> > add controls in your button click. This will not work for you because

> during
> > postback those controls wont be recreated. so set a flag in viewstate as

> you
> > add the control.
> > Also I have noticed that you are trying to retrieve the same button, the

> one
> > that fired the event in its event click and add it to the controls
> > collection. This is not what what you need to do, but simply have the

same
> > code run after postback. Whatever code you have in your

> createchildcontrols
> > method will run after postback, so let it all run as is and remove the
> > ispostback check in there --If that code is not run your event will

never
> > fire, this is because the viewstate of the control is restored when the
> > control is reloaded into its container.
> >
> > Private Sub ButtonClick(ByVal sender As Object, ByVal e As

> System.EventArgs)
> > Dim MyButton As New Button()
> > MyButton = CType(sender, Button)
> > context.response.write("Click event for " & MyButton.id & "Fired")
> > End Sub
> >
> >

>

http://samples.gotdotnet.com/quickst...ion2.vb&font=3
> >
> > This is another example :
> >

>

http://samples.gotdotnet.com/quickst...ion3.vb&font=3
> >
> >
> > "ton" <(E-Mail Removed)> wrote in message
> > news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > > 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" <(E-Mail Removed)> schreef

> in
> > > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > > 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 theorically this

is
> > all
> > > > you need if this is your requirement. This is useful if you need to

> take
> > > > action without exposing the event to the container page, giving the
> > > > consumers of your control no control, as this event is not exposed

to
> > > them.
> > > >
> > > > for a complete example that digs deeper into this you might want to

> look
> > > at
> > > > the following link :
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > >
> > > >
> > > > Instead if you need to expose this event to the page where your

> control
> > > > sits, and exposed to the end users of your control then you will

need
> to
> > > > bubble it up .
> > > > Here is a very nice example of how this can be done for composite

> > controls
> > > > on MSDN.
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > >
> > > > "ton" <(E-Mail Removed)> wrote in message
> > > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > > In the procedure CreateChildControls I add several controls like

> check
> > > and
> > > > > textboxes, button link and so on. How can I get the postback

respons
> > on
> > > > the
> > > > > button link:
> > > > > The functions:
> > > > > lblButtonLink_Command and lblButtonLink_Click will not be executed
> > > > >
> > > > > Please help
> > > > >
> > > > > Ton
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
ton
Guest
Posts: n/a
 
      02-02-2004
thank you
the event is fired now but what I had in my does not occur:
What I do is the following:
- I show a record contains of 10 fields. The properties are:
Tablename, RecordID, ShowFields (just a list of the fields to show)
now pressing a button should replace the existing recordcard by another
record card. For example a record contains a Contact. One of the field is
the (database)-link to the Customer. To click on that buttonlink, should
replace the form with for example 10 fields of the customer. You can say it
is a zoom function to the toplevel of the database.
For me this is inportant because it let me navigate in the database.
Another example:
when I want to modify the link I want to replace the control with a search
screen to show a list of customers, where the user can select one. Or to add
a complete knew one.

The question is: "Is this possible". I do not want the webdesigner to add
several controls on the form or to add several forms to the project to
handle these evenst.

Ton


"Alessandro Zifiglio" <(E-Mail Removed)> schreef in
bericht newsZpSb.1500$(E-Mail Removed)...
> oops, no workaround. That InamingContainer Interface had me a little
> confused ;P
> Since this interface already makes control ids unique you just need to

pass
> your id as is like
>
> button1.id = "button1"
> textbox1.id = "textbox1"
> and so forth.
> When trying to reference textbox1 for example just simply use its id
> "Alessandro Zifiglio" <(E-Mail Removed)> wrote in
> message news:cmpSb.1494$(E-Mail Removed)...
> > ton, Look at the post "No events are fired in child controls". Jeffery

has
> > just pointed out how useful Implementing the InamingContainer interface
> > really is, especially when you need events in child controls routed.

This
> is
> > why your events werent firing.
> >
> > Iimplement this interface, and do not try passing an explicit id to your
> > control if you dont need it.
> >
> > At the moment i myself am having problems passing an explict id to child
> > controls and i'm working on a workaround. Will postback when I do find a
> > way. One good reason to want to pass an explicit id is when using a
> > validator control and as you already know you need to pass your controls

> id
> > to its "controlToValidate" property.
> >
> > If this is not your case then i dont see why it is important to pass an
> > explicit ID
> >
> > "Alessandro Zifiglio" <(E-Mail Removed)> wrote in
> > message news:ZeeSb.1334$(E-Mail Removed)...
> > > Should fire. It works for me. However i have noticed that you are

trying
> > to
> > > add controls in your button click. This will not work for you because

> > during
> > > postback those controls wont be recreated. so set a flag in viewstate

as
> > you
> > > add the control.
> > > Also I have noticed that you are trying to retrieve the same button,

the
> > one
> > > that fired the event in its event click and add it to the controls
> > > collection. This is not what what you need to do, but simply have the

> same
> > > code run after postback. Whatever code you have in your

> > createchildcontrols
> > > method will run after postback, so let it all run as is and remove the
> > > ispostback check in there --If that code is not run your event will

> never
> > > fire, this is because the viewstate of the control is restored when

the
> > > control is reloaded into its container.
> > >
> > > Private Sub ButtonClick(ByVal sender As Object, ByVal e As

> > System.EventArgs)
> > > Dim MyButton As New Button()
> > > MyButton = CType(sender, Button)
> > > context.response.write("Click event for " & MyButton.id & "Fired")
> > > End Sub
> > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...ion2.vb&font=3
> > >
> > > This is another example :
> > >

> >

>

http://samples.gotdotnet.com/quickst...ion3.vb&font=3
> > >
> > >
> > > "ton" <(E-Mail Removed)> wrote in message
> > > news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > > > 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" <(E-Mail Removed)>

schreef
> > in
> > > > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > > > 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 theorically this

> is
> > > all
> > > > > you need if this is your requirement. This is useful if you need

to
> > take
> > > > > action without exposing the event to the container page, giving

the
> > > > > consumers of your control no control, as this event is not exposed

> to
> > > > them.
> > > > >
> > > > > for a complete example that digs deeper into this you might want

to
> > look
> > > > at
> > > > > the following link :
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > > >
> > > > >
> > > > > Instead if you need to expose this event to the page where your

> > control
> > > > > sits, and exposed to the end users of your control then you will

> need
> > to
> > > > > bubble it up .
> > > > > Here is a very nice example of how this can be done for composite
> > > controls
> > > > > on MSDN.
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > > >
> > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > > > In the procedure CreateChildControls I add several controls like

> > check
> > > > and
> > > > > > textboxes, button link and so on. How can I get the postback

> respons
> > > on
> > > > > the
> > > > > > button link:
> > > > > > The functions:
> > > > > > lblButtonLink_Command and lblButtonLink_Click will not be

executed
> > > > > >
> > > > > > Please help
> > > > > >
> > > > > > Ton
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      02-02-2004
ton, Can you explain that again. Its not very clear what you want to do ;P


"ton" <(E-Mail Removed)> wrote in message
news:bvl8va$khs$(E-Mail Removed)1.nb.home.nl...
> thank you
> the event is fired now but what I had in my does not occur:
> What I do is the following:
> - I show a record contains of 10 fields. The properties are:
> Tablename, RecordID, ShowFields (just a list of the fields to show)
> now pressing a button should replace the existing recordcard by another
> record card. For example a record contains a Contact. One of the field is
> the (database)-link to the Customer. To click on that buttonlink, should
> replace the form with for example 10 fields of the customer. You can say

it
> is a zoom function to the toplevel of the database.
> For me this is inportant because it let me navigate in the database.
> Another example:
> when I want to modify the link I want to replace the control with a search
> screen to show a list of customers, where the user can select one. Or to

add
> a complete knew one.
>
> The question is: "Is this possible". I do not want the webdesigner to add
> several controls on the form or to add several forms to the project to
> handle these evenst.
>
> Ton
>
>
> "Alessandro Zifiglio" <(E-Mail Removed)> schreef in
> bericht newsZpSb.1500$(E-Mail Removed)...
> > oops, no workaround. That InamingContainer Interface had me a little
> > confused ;P
> > Since this interface already makes control ids unique you just need to

> pass
> > your id as is like
> >
> > button1.id = "button1"
> > textbox1.id = "textbox1"
> > and so forth.
> > When trying to reference textbox1 for example just simply use its id
> > "Alessandro Zifiglio" <(E-Mail Removed)> wrote in
> > message news:cmpSb.1494$(E-Mail Removed)...
> > > ton, Look at the post "No events are fired in child controls". Jeffery

> has
> > > just pointed out how useful Implementing the InamingContainer

interface
> > > really is, especially when you need events in child controls routed.

> This
> > is
> > > why your events werent firing.
> > >
> > > Iimplement this interface, and do not try passing an explicit id to

your
> > > control if you dont need it.
> > >
> > > At the moment i myself am having problems passing an explict id to

child
> > > controls and i'm working on a workaround. Will postback when I do find

a
> > > way. One good reason to want to pass an explicit id is when using a
> > > validator control and as you already know you need to pass your

controls
> > id
> > > to its "controlToValidate" property.
> > >
> > > If this is not your case then i dont see why it is important to pass

an
> > > explicit ID
> > >
> > > "Alessandro Zifiglio" <(E-Mail Removed)> wrote

in
> > > message news:ZeeSb.1334$(E-Mail Removed)...
> > > > Should fire. It works for me. However i have noticed that you are

> trying
> > > to
> > > > add controls in your button click. This will not work for you

because
> > > during
> > > > postback those controls wont be recreated. so set a flag in

viewstate
> as
> > > you
> > > > add the control.
> > > > Also I have noticed that you are trying to retrieve the same button,

> the
> > > one
> > > > that fired the event in its event click and add it to the controls
> > > > collection. This is not what what you need to do, but simply have

the
> > same
> > > > code run after postback. Whatever code you have in your
> > > createchildcontrols
> > > > method will run after postback, so let it all run as is and remove

the
> > > > ispostback check in there --If that code is not run your event will

> > never
> > > > fire, this is because the viewstate of the control is restored when

> the
> > > > control is reloaded into its container.
> > > >
> > > > Private Sub ButtonClick(ByVal sender As Object, ByVal e As
> > > System.EventArgs)
> > > > Dim MyButton As New Button()
> > > > MyButton = CType(sender, Button)
> > > > context.response.write("Click event for " & MyButton.id & "Fired")
> > > > End Sub
> > > >
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...ion2.vb&font=3
> > > >
> > > > This is another example :
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...ion3.vb&font=3
> > > >
> > > >
> > > > "ton" <(E-Mail Removed)> wrote in message
> > > > news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > > > > 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" <(E-Mail Removed)>

> schreef
> > > in
> > > > > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > > > > 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 theorically

this
> > is
> > > > all
> > > > > > you need if this is your requirement. This is useful if you need

> to
> > > take
> > > > > > action without exposing the event to the container page, giving

> the
> > > > > > consumers of your control no control, as this event is not

exposed
> > to
> > > > > them.
> > > > > >
> > > > > > for a complete example that digs deeper into this you might want

> to
> > > look
> > > > > at
> > > > > > the following link :
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > > > >
> > > > > >
> > > > > > Instead if you need to expose this event to the page where your
> > > control
> > > > > > sits, and exposed to the end users of your control then you will

> > need
> > > to
> > > > > > bubble it up .
> > > > > > Here is a very nice example of how this can be done for

composite
> > > > controls
> > > > > > on MSDN.
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...trolsample.asp
> > > > > >
> > > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > > > > In the procedure CreateChildControls I add several controls

like
> > > check
> > > > > and
> > > > > > > textboxes, button link and so on. How can I get the postback

> > respons
> > > > on
> > > > > > the
> > > > > > > button link:
> > > > > > > The functions:
> > > > > > > lblButtonLink_Command and lblButtonLink_Click will not be

> executed
> > > > > > >
> > > > > > > Please help
> > > > > > >
> > > > > > > Ton
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
ton
Guest
Posts: n/a
 
      02-02-2004
suppose you want to plan an activity. You get a card wich contains several
field like
date, begintime, end time, description, customer, type of activity and so
on
type of activity is a dropdonlist
description a textbox
and the customer fields points to a foreignkey with the customer-table (if
it is filled in I just show the customer name)
off cause i cannot use a drop down list because there will be hunderds or
thoussends of customers in the database
so when it is empty i can press a button to select one from a list (get e
search screen and then look up)
or i can add a new customer, in both situations I want to have a different
from as the replacement of my original activity:
- pick from a list will show me several search fields from the table
customer inclusive a Search button
- the add new customer will give me a recordcard with the important fields
to define a new customer
when the customer is add, or when the customer is selected from the list I
replace this card by the original content where the customer field shows the
name of the customer

So instead of multiple screens i just use the same screens to collect the
information to plan this activity

i hope you can help


Ton



"Alessandro Zifiglio" <(E-Mail Removed)> schreef in
bericht news:HOrTb.2542$(E-Mail Removed)...
> ton, Can you explain that again. Its not very clear what you want to do

;P
>
>
> "ton" <(E-Mail Removed)> wrote in message
> news:bvl8va$khs$(E-Mail Removed)1.nb.home.nl...
> > thank you
> > the event is fired now but what I had in my does not occur:
> > What I do is the following:
> > - I show a record contains of 10 fields. The properties are:
> > Tablename, RecordID, ShowFields (just a list of the fields to show)
> > now pressing a button should replace the existing recordcard by another
> > record card. For example a record contains a Contact. One of the field

is
> > the (database)-link to the Customer. To click on that buttonlink, should
> > replace the form with for example 10 fields of the customer. You can say

> it
> > is a zoom function to the toplevel of the database.
> > For me this is inportant because it let me navigate in the database.
> > Another example:
> > when I want to modify the link I want to replace the control with a

search
> > screen to show a list of customers, where the user can select one. Or to

> add
> > a complete knew one.
> >
> > The question is: "Is this possible". I do not want the webdesigner to

add
> > several controls on the form or to add several forms to the project to
> > handle these evenst.
> >
> > Ton
> >
> >
> > "Alessandro Zifiglio" <(E-Mail Removed)> schreef

in
> > bericht newsZpSb.1500$(E-Mail Removed)...
> > > oops, no workaround. That InamingContainer Interface had me a little
> > > confused ;P
> > > Since this interface already makes control ids unique you just need

to
> > pass
> > > your id as is like
> > >
> > > button1.id = "button1"
> > > textbox1.id = "textbox1"
> > > and so forth.
> > > When trying to reference textbox1 for example just simply use its id
> > > "Alessandro Zifiglio" <(E-Mail Removed)> wrote

in
> > > message news:cmpSb.1494$(E-Mail Removed)...
> > > > ton, Look at the post "No events are fired in child controls".

Jeffery
> > has
> > > > just pointed out how useful Implementing the InamingContainer

> interface
> > > > really is, especially when you need events in child controls routed.

> > This
> > > is
> > > > why your events werent firing.
> > > >
> > > > Iimplement this interface, and do not try passing an explicit id to

> your
> > > > control if you dont need it.
> > > >
> > > > At the moment i myself am having problems passing an explict id to

> child
> > > > controls and i'm working on a workaround. Will postback when I do

find
> a
> > > > way. One good reason to want to pass an explicit id is when using a
> > > > validator control and as you already know you need to pass your

> controls
> > > id
> > > > to its "controlToValidate" property.
> > > >
> > > > If this is not your case then i dont see why it is important to pass

> an
> > > > explicit ID
> > > >
> > > > "Alessandro Zifiglio" <(E-Mail Removed)> wrote

> in
> > > > message news:ZeeSb.1334$(E-Mail Removed)...
> > > > > Should fire. It works for me. However i have noticed that you are

> > trying
> > > > to
> > > > > add controls in your button click. This will not work for you

> because
> > > > during
> > > > > postback those controls wont be recreated. so set a flag in

> viewstate
> > as
> > > > you
> > > > > add the control.
> > > > > Also I have noticed that you are trying to retrieve the same

button,
> > the
> > > > one
> > > > > that fired the event in its event click and add it to the controls
> > > > > collection. This is not what what you need to do, but simply have

> the
> > > same
> > > > > code run after postback. Whatever code you have in your
> > > > createchildcontrols
> > > > > method will run after postback, so let it all run as is and remove

> the
> > > > > ispostback check in there --If that code is not run your event

will
> > > never
> > > > > fire, this is because the viewstate of the control is restored

when
> > the
> > > > > control is reloaded into its container.
> > > > >
> > > > > Private Sub ButtonClick(ByVal sender As Object, ByVal e As
> > > > System.EventArgs)
> > > > > Dim MyButton As New Button()
> > > > > MyButton = CType(sender, Button)
> > > > > context.response.write("Click event for " & MyButton.id & "Fired")
> > > > > End Sub
> > > > >
> > > > >
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...=/quickstart/a
spplus/samples/webforms/ctrlauth/composition/Composition2.src&file=VB\Compos
ition2.vb&font=3
> > > > >
> > > > > This is another example :
> > > > >
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...=/quickstart/a
spplus/samples/webforms/ctrlauth/composition/Composition3.src&file=VB\Compos
ition3.vb&font=3
> > > > >
> > > > >
> > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > > > > > 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" <(E-Mail Removed)>

> > schreef
> > > > in
> > > > > > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > > > > > 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 theorically

> this
> > > is
> > > > > all
> > > > > > > you need if this is your requirement. This is useful if you

need
> > to
> > > > take
> > > > > > > action without exposing the event to the container page,

giving
> > the
> > > > > > > consumers of your control no control, as this event is not

> exposed
> > > to
> > > > > > them.
> > > > > > >
> > > > > > > for a complete example that digs deeper into this you might

want
> > to
> > > > look
> > > > > > at
> > > > > > > the following link :
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcompositecontrolsample.asp
> > > > > > >
> > > > > > >
> > > > > > > Instead if you need to expose this event to the page where

your
> > > > control
> > > > > > > sits, and exposed to the end users of your control then you

will
> > > need
> > > > to
> > > > > > > bubble it up .
> > > > > > > Here is a very nice example of how this can be done for

> composite
> > > > > controls
> > > > > > > on MSDN.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconeventbubblingcontrolsample.asp
> > > > > > >
> > > > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > > > > > In the procedure CreateChildControls I add several controls

> like
> > > > check
> > > > > > and
> > > > > > > > textboxes, button link and so on. How can I get the postback
> > > respons
> > > > > on
> > > > > > > the
> > > > > > > > button link:
> > > > > > > > The functions:
> > > > > > > > lblButtonLink_Command and lblButtonLink_Click will not be

> > executed
> > > > > > > >
> > > > > > > > Please help
> > > > > > > >
> > > > > > > > Ton
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      02-02-2004
still not clear to me. Instead of defining a scenario can you simplify it
and explain it in terms of custom control building what is not working for
you. Is your requirement to build a databound custom server control ? Are
you looking into building a custom control that has similar functionality to
the datagrid, datalist, repeater and so on --what have you been able to
implement so far. Which parts are working and where are you stuck.

"ton" <(E-Mail Removed)> wrote in message
news:bvlkqi$v3s$(E-Mail Removed)1.nb.home.nl...
> suppose you want to plan an activity. You get a card wich contains several
> field like
> date, begintime, end time, description, customer, type of activity and so
> on
> type of activity is a dropdonlist
> description a textbox
> and the customer fields points to a foreignkey with the customer-table (if
> it is filled in I just show the customer name)
> off cause i cannot use a drop down list because there will be hunderds or
> thoussends of customers in the database
> so when it is empty i can press a button to select one from a list (get e
> search screen and then look up)
> or i can add a new customer, in both situations I want to have a different
> from as the replacement of my original activity:
> - pick from a list will show me several search fields from the table
> customer inclusive a Search button
> - the add new customer will give me a recordcard with the important fields
> to define a new customer
> when the customer is add, or when the customer is selected from the list I
> replace this card by the original content where the customer field shows

the
> name of the customer
>
> So instead of multiple screens i just use the same screens to collect the
> information to plan this activity
>
> i hope you can help
>
>
> Ton
>
>
>
> "Alessandro Zifiglio" <(E-Mail Removed)> schreef in
> bericht news:HOrTb.2542$(E-Mail Removed)...
> > ton, Can you explain that again. Its not very clear what you want to do

> ;P
> >
> >
> > "ton" <(E-Mail Removed)> wrote in message
> > news:bvl8va$khs$(E-Mail Removed)1.nb.home.nl...
> > > thank you
> > > the event is fired now but what I had in my does not occur:
> > > What I do is the following:
> > > - I show a record contains of 10 fields. The properties are:
> > > Tablename, RecordID, ShowFields (just a list of the fields to show)
> > > now pressing a button should replace the existing recordcard by

another
> > > record card. For example a record contains a Contact. One of the field

> is
> > > the (database)-link to the Customer. To click on that buttonlink,

should
> > > replace the form with for example 10 fields of the customer. You can

say
> > it
> > > is a zoom function to the toplevel of the database.
> > > For me this is inportant because it let me navigate in the database.
> > > Another example:
> > > when I want to modify the link I want to replace the control with a

> search
> > > screen to show a list of customers, where the user can select one. Or

to
> > add
> > > a complete knew one.
> > >
> > > The question is: "Is this possible". I do not want the webdesigner to

> add
> > > several controls on the form or to add several forms to the project to
> > > handle these evenst.
> > >
> > > Ton
> > >
> > >
> > > "Alessandro Zifiglio" <(E-Mail Removed)> schreef

> in
> > > bericht newsZpSb.1500$(E-Mail Removed)...
> > > > oops, no workaround. That InamingContainer Interface had me a little
> > > > confused ;P
> > > > Since this interface already makes control ids unique you just need

> to
> > > pass
> > > > your id as is like
> > > >
> > > > button1.id = "button1"
> > > > textbox1.id = "textbox1"
> > > > and so forth.
> > > > When trying to reference textbox1 for example just simply use its id
> > > > "Alessandro Zifiglio" <(E-Mail Removed)> wrote

> in
> > > > message news:cmpSb.1494$(E-Mail Removed)...
> > > > > ton, Look at the post "No events are fired in child controls".

> Jeffery
> > > has
> > > > > just pointed out how useful Implementing the InamingContainer

> > interface
> > > > > really is, especially when you need events in child controls

routed.
> > > This
> > > > is
> > > > > why your events werent firing.
> > > > >
> > > > > Iimplement this interface, and do not try passing an explicit id

to
> > your
> > > > > control if you dont need it.
> > > > >
> > > > > At the moment i myself am having problems passing an explict id to

> > child
> > > > > controls and i'm working on a workaround. Will postback when I do

> find
> > a
> > > > > way. One good reason to want to pass an explicit id is when using

a
> > > > > validator control and as you already know you need to pass your

> > controls
> > > > id
> > > > > to its "controlToValidate" property.
> > > > >
> > > > > If this is not your case then i dont see why it is important to

pass
> > an
> > > > > explicit ID
> > > > >
> > > > > "Alessandro Zifiglio" <(E-Mail Removed)>

wrote
> > in
> > > > > message news:ZeeSb.1334$(E-Mail Removed)...
> > > > > > Should fire. It works for me. However i have noticed that you

are
> > > trying
> > > > > to
> > > > > > add controls in your button click. This will not work for you

> > because
> > > > > during
> > > > > > postback those controls wont be recreated. so set a flag in

> > viewstate
> > > as
> > > > > you
> > > > > > add the control.
> > > > > > Also I have noticed that you are trying to retrieve the same

> button,
> > > the
> > > > > one
> > > > > > that fired the event in its event click and add it to the

controls
> > > > > > collection. This is not what what you need to do, but simply

have
> > the
> > > > same
> > > > > > code run after postback. Whatever code you have in your
> > > > > createchildcontrols
> > > > > > method will run after postback, so let it all run as is and

remove
> > the
> > > > > > ispostback check in there --If that code is not run your event

> will
> > > > never
> > > > > > fire, this is because the viewstate of the control is restored

> when
> > > the
> > > > > > control is reloaded into its container.
> > > > > >
> > > > > > Private Sub ButtonClick(ByVal sender As Object, ByVal e As
> > > > > System.EventArgs)
> > > > > > Dim MyButton As New Button()
> > > > > > MyButton = CType(sender, Button)
> > > > > > context.response.write("Click event for " & MyButton.id &

"Fired")
> > > > > > End Sub
> > > > > >
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...=/quickstart/a
>

spplus/samples/webforms/ctrlauth/composition/Composition2.src&file=VB\Compos
> ition2.vb&font=3
> > > > > >
> > > > > > This is another example :
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://samples.gotdotnet.com/quickst...=/quickstart/a
>

spplus/samples/webforms/ctrlauth/composition/Composition3.src&file=VB\Compos
> ition3.vb&font=3
> > > > > >
> > > > > >
> > > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > > news:bvboj3$gbo$(E-Mail Removed)1.nb.home.nl...
> > > > > > > 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" <(E-Mail Removed)>
> > > schreef
> > > > > in
> > > > > > > bericht news:9DbSb.1271$(E-Mail Removed)...
> > > > > > > > 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

theorically
> > this
> > > > is
> > > > > > all
> > > > > > > > you need if this is your requirement. This is useful if you

> need
> > > to
> > > > > take
> > > > > > > > action without exposing the event to the container page,

> giving
> > > the
> > > > > > > > consumers of your control no control, as this event is not

> > exposed
> > > > to
> > > > > > > them.
> > > > > > > >
> > > > > > > > for a complete example that digs deeper into this you might

> want
> > > to
> > > > > look
> > > > > > > at
> > > > > > > > the following link :
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...us/cpguide/htm
> l/cpconcompositecontrolsample.asp
> > > > > > > >
> > > > > > > >
> > > > > > > > Instead if you need to expose this event to the page where

> your
> > > > > control
> > > > > > > > sits, and exposed to the end users of your control then you

> will
> > > > need
> > > > > to
> > > > > > > > bubble it up .
> > > > > > > > Here is a very nice example of how this can be done for

> > composite
> > > > > > controls
> > > > > > > > on MSDN.
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://msdn.microsoft.com/library/de...us/cpguide/htm
> l/cpconeventbubblingcontrolsample.asp
> > > > > > > >
> > > > > > > > "ton" <(E-Mail Removed)> wrote in message
> > > > > > > > news:bvav9a$pjr$(E-Mail Removed)1.nb.home.nl...
> > > > > > > > > In the procedure CreateChildControls I add several

controls
> > like
> > > > > check
> > > > > > > and
> > > > > > > > > textboxes, button link and so on. How can I get the

postback
> > > > respons
> > > > > > on
> > > > > > > > the
> > > > > > > > > button link:
> > > > > > > > > The functions:
> > > > > > > > > lblButtonLink_Command and lblButtonLink_Click will not be
> > > executed
> > > > > > > > >
> > > > > > > > > Please help
> > > > > > > > >
> > > > > > > > > Ton
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
this.Controls.Add(Control) Does Not Add Control to child collection (this.Controls.Count == 0) Chad Scharf ASP .Net 3 10-18-2007 03:53 PM
stop postback in postback events for server controls ?? Wael_Bakr ASP .Net Web Controls 0 11-30-2005 08:06 AM
Custom controls instance problem on PostBack - two controls, one instance ??? Dejan Vesic ASP .Net Web Controls 0 08-20-2003 02:43 PM



Advertisments