473,660 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10601
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 "OnBubbleEv ent" 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.goo glegroups.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.Te xt = "Beethoven"
tdComposers.Con trols.Add(tdLbC omposer)
'============== =============== ======

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.goo glegroups.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.Te xt = "Beethoven"
tdComposers.Con trols.Add(tdLbC omposer)
'============== =============== ======

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.goo glegroups.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.Te xt = "Beethoven"
tdComposers.Con trols.Add(tdLbC omposer)
'============== =============== ======

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
7726
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 which will be used to query sql server to repopulate the datagrid in the user control. I also wrapped the user control in a panel element so I could position it on the page. I'm clueless on how to get started with this.
0
1660
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 this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want to Change the Back Color of the Clicked to LinkButton To a different color and i also don't want to...
4
4478
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 server event to fire to update the database. I've successfully done this with a normal webcontrol via: myControl.Attributes("onclick") = "javascript:alert('You clicked me!!');" In that case, myControl is an asp:button on the page. In the...
4
4793
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, has command name and argument attached and is assigned a unique id. If I use this control on a web form everything works fine, the event fires as planned. However if I contain the control inside another user control, the event on the linkbutton...
0
1001
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 id="Prevbutton" onclick="PagerButton_Click" runat="server" Text="" CommandArgument="Prev"></asp:linkbutton> and i have code behind like this
5
2213
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 link buttons. Once I click the button, I would like to make it bold using instructions like linkbutton.font.bold=true This works as long as its NOT followed by response.redirect
6
1380
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 the grid information before it renders. Once a conrol's event finishes is there a way to run a method on the parent page so I can update the gid? Any thoughs on how I might accomplish this?
4
1729
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 at my code segments and provide any insight in a reply, I would be eternally grateful. My table name is "rfi" and the field with a dropdownlist control is called "contract". I have imported the System.Data and System.Data.OleDb libraries. ...
1
296
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 it. I then want to build the control programmatically on page load.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.