473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

User Control and dynamic LinkButton problem

Hi everyone!
I've made quite a lot of research on this, and I've tried a couple of
proposed solutions. Nothing has worked for me, but I feel there's not
much I'm missing. So I'm turning to this group and its experts for
answers.

So :
- I've got a main page (main.aspx)
- On this page, I've got a button (btnArchive), on whose click I
dynamically add a UserControl (archive.ascx) to the main page.
- Now on the PageLoad of the UserControl, I dynamically add several
LinkButtons.

- My dilemma lies here : on the click of one of these LinkButtons, I
wish to tell the main page to load a different UserControl (depending
on which LinkButton was clicked).

Thus, I imagine I need the LinkButtons to raise an event on the main
form and somehow pass the LinkButton's ID to the raised event, in order
to process the right UserControl load.

Hope I've been clear on this one. If anyone could help me with this,
I'd greatly appreciate. I could also post some sample code if it could
help.
Also, I'm programming in VB.NET, but I don't mind anyone anwsering with
C# ; I'll figure the translation.

Thanks and good day!
Simon.

Nov 19 '05 #1
4 10582
Simon,

The button's are already notifying the main page that they were clicked with
something called a bubble event. You may override the OnBubbleEvent within
the main page to see which button(s) in a control are being clicked:

I have some sample code on my website
http://www.aboutfortunate.com/defaul...ge=codelibrary

That shows how to use the OnBubbleEvent. Just use the search box on the page
above to search for "OnBubbleEvent" and you'll have the code you need.

If you have any other questions about it feel free to email me.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Fueled" <po************@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi everyone!
I've made quite a lot of research on this, and I've tried a couple of
proposed solutions. Nothing has worked for me, but I feel there's not
much I'm missing. So I'm turning to this group and its experts for
answers.

So :
- I've got a main page (main.aspx)
- On this page, I've got a button (btnArchive), on whose click I
dynamically add a UserControl (archive.ascx) to the main page.
- Now on the PageLoad of the UserControl, I dynamically add several
LinkButtons.

- My dilemma lies here : on the click of one of these LinkButtons, I
wish to tell the main page to load a different UserControl (depending
on which LinkButton was clicked).

Thus, I imagine I need the LinkButtons to raise an event on the main
form and somehow pass the LinkButton's ID to the raised event, in order
to process the right UserControl load.

Hope I've been clear on this one. If anyone could help me with this,
I'd greatly appreciate. I could also post some sample code if it could
help.
Also, I'm programming in VB.NET, but I don't mind anyone anwsering with
C# ; I'll figure the translation.

Thanks and good day!
Simon.

Nov 19 '05 #2
Thank you Justin for this piece of code, I bet it'll be useful.

I created the Overrides OnBubbleEvent function, and it fires fine from
the button on the Main page (btnArchive) and I'm able to get the
button's ID.
But it still does not fire from the LinkButton's click on the
UserControl. I don't know what could be the problem.

Here's how I create and add my LinkButton (it's added to a TD in a
table, during the UserControl's PageLoad) :

'===================================
Dim tdLbComposer As New LinkButton

tdLbComposer.ID = "lbComposer"
tdLbComposer.Text = "Beethoven"
tdComposers.Controls.Add(tdLbComposer)
'===================================

Is it possible that the LinkButton control doesn't fire this event?
Because I've tried adding a simple Button on the UserControl, and its
click does fire the event! I'll make some inquiring on this matter.
Thanks,
Simon.

Nov 19 '05 #3
Simon,

Controls added dynamically need to be recreated on post back for their
events to fire.

I have some sample code for dynamically adding controls on my website in the
code library. If you do a search for "dynamic controls" those examples may
help you.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Fueled" <po************@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Thank you Justin for this piece of code, I bet it'll be useful.

I created the Overrides OnBubbleEvent function, and it fires fine from
the button on the Main page (btnArchive) and I'm able to get the
button's ID.
But it still does not fire from the LinkButton's click on the
UserControl. I don't know what could be the problem.

Here's how I create and add my LinkButton (it's added to a TD in a
table, during the UserControl's PageLoad) :

'===================================
Dim tdLbComposer As New LinkButton

tdLbComposer.ID = "lbComposer"
tdLbComposer.Text = "Beethoven"
tdComposers.Controls.Add(tdLbComposer)
'===================================

Is it possible that the LinkButton control doesn't fire this event?
Because I've tried adding a simple Button on the UserControl, and its
click does fire the event! I'll make some inquiring on this matter.
Thanks,
Simon.

Nov 19 '05 #4
Thanks again for your response.

You see, the thing is that even a LinkButton created at design-time
does NOT fire the OnBubbleEvent, and more so, a Button created
dynamically DOES fire the event!

So I don't see why reloading would be useful here, since dynamic Button
controls do fire the events.
I juste need to find out what's particular with the LinkButton control.

Thanks anyway!
Simon.
S. Justin Gengo a écrit :
Simon,

Controls added dynamically need to be recreated on post back for their
events to fire.

I have some sample code for dynamically adding controls on my website in the
code library. If you do a search for "dynamic controls" those examples may
help you.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Fueled" <po************@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Thank you Justin for this piece of code, I bet it'll be useful.

I created the Overrides OnBubbleEvent function, and it fires fine from
the button on the Main page (btnArchive) and I'm able to get the
button's ID.
But it still does not fire from the LinkButton's click on the
UserControl. I don't know what could be the problem.

Here's how I create and add my LinkButton (it's added to a TD in a
table, during the UserControl's PageLoad) :

'===================================
Dim tdLbComposer As New LinkButton

tdLbComposer.ID = "lbComposer"
tdLbComposer.Text = "Beethoven"
tdComposers.Controls.Add(tdLbComposer)
'===================================

Is it possible that the LinkButton control doesn't fire this event?
Because I've tried adding a simple Button on the UserControl, and its
click does fire the event! I'll make some inquiring on this matter.
Thanks,
Simon.


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
0
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to...
4
by: Barb | last post by:
I have a user control as my Save button for my page. When the Save button is clicked, I want some client-side validation to take place from a javascript function in the page, and then I'd like the...
4
by: vatech1993 | last post by:
I'm stumped on this problem. I've created a user control that dynamically creates 5 linkbuttons in the CreateChildControls method. Each of these child controls is linked to a commandeventhandler,...
0
by: ferryandi | last post by:
hi i created a linkbutton with this code in html <asp:linkbutton id="Nextbutton" onclick="PagerButton_Click" runat="server" Text="" CommandArgument="Next"></asp:linkbutton> <asp:linkbutton...
5
by: Trisha | last post by:
I have a navigation user control navig.ascx that redirects to respective pages based on webcontrols.linkbutton clicks using response.redirect. I would like to control the look and feel of those...
6
by: Rob Morgan | last post by:
I have a grid and a user control on the same page. The user control has a save button that triggers a click event server side. Once the click event happens the page renders, but I need to update...
4
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak...
1
by: Rotsey | last post by:
Hi I have a ASP.NET 2.0 problem I hope you could help me with, I have had problems trying to find an answer to this I will be brief. I have a user control that has only a <asp:table> tag on...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.