How to duplicate a control?

N

Neo

Hi,

I want to place two buttons on the page. These two button are identical.Is
there a way to duplicate a button? or I have to assign all properties of one
button to another.

Thanks in advance.

Neo
 
N

Neo

Hi Victor,

Actually, what I want to do is to add two identical buttons on the page.
It seems that a button can not be added twice on the page.(I tried to add a
button to two placeholders and only last placeholder had the button)

So is there a way to add identical buttons on the page or an easy way to
copy one button's property to another?

Thanks

Neo
 
D

Donald Welker

You can't add two buttons to the page with the same ID. I'm assuming these
are both server-side button controls. What you could do is create a new
button with a different ID and the same value like

<asp:Button id="Button1" runat="server" Text="Button"
OnClick="Button_OnClick"></asp:Button>
....
<asp:Button id="Button2" runat="server" Text="Button"
OnClick="Button_OnClick"></asp:Button>

This way the same method (Button_OnClick) will be called when either one is
clicked but they both look the same. My understanding is that
Button1_OnClick and Button2_OnClick events are also available, so you could
leave the OnClick property out and call Button_OnClick from each event
handler.
 
D

David Jessee

You'll need to delve into System.Reflection for that one.

Look at the PropertyInfo class. Make sure they have differentID's though
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top