Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > rendering Button inside Render() event, makes it loose its click event handler association

Reply
Thread Tools

rendering Button inside Render() event, makes it loose its click event handler association

 
 
sonic
Guest
Posts: n/a
 
      01-07-2005
I generate a button link control in following Manner.

Button b = new Button();
b.Click = MyEventHandler(...);

If i add this button to current control with:
this.Controls.Add( b );
it will render, and its clicked event will be triggered properly.
Unfortunately I do not have alot of control over where the button shows
up.

So I try to render it inside of protected override Render(...) event
with:
b.RenderControl( writer );

Now the button shows up where I want it to, but its click event never
triggers anymore.

Any ideas why rendering it manually cancels out its click event
association?

 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      01-07-2005
"sonic" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>I generate a button link control in following Manner.
>
> Button b = new Button();
> b.Click = MyEventHandler(...);
>
> If i add this button to current control with:
> this.Controls.Add( b );
> it will render, and its clicked event will be triggered properly.
> Unfortunately I do not have alot of control over where the button shows
> up.
>
> So I try to render it inside of protected override Render(...) event
> with:
> b.RenderControl( writer );
>
> Now the button shows up where I want it to, but its click event never
> triggers anymore.
>
> Any ideas why rendering it manually cancels out its click event
> association?


Because it's not part of the control hierarchy. It's not because you
rendered it manually, it's because you didn't add it to the Controls
collection.

Note that you can control where such a child control renders by using tables
for layout and adding the child control to the appropriate TableCell.

Also, a control in the Controls collection renders only when you call
base.Render in your Render method. If you can do your rendering without
calling base.Render, then you can have a control in the Controls collection
and at the same time you can determine where it will render within the HTML:

John Saunders


 
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
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Web Controls 0 05-25-2004 01:45 AM



Advertisments