Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 23, 2012 02:13 PM by ramiramilu
Member
112 Points
128 Posts
Apr 23, 2012 01:21 PM|LINK
Hi Guys,
Here's something that someone could answer in their sleep. How do I from the code behind place multiple Hyperlink Buttons on a page with the same ID except the number is increasing by 1 each time. So for example:
<asp:hyperlink ID="File1" runat="server"/> <asp:hyperlink ID="File2" runat="server"/> <asp:hyperlink ID="File3" runat="server"/> .......
Or how do I create Hyperlink buttons in the code behind with a ID and the render them to a panel?
Thanks guys for any Input that you can have on this.
All-Star
18265 Points
2731 Posts
Apr 23, 2012 01:27 PM|LINK
Use the following:
for (int i=1;i<=5;i++) { HyperLink h = new HyperLink(); //Set some other properties h.ID = "File"+i.ToString(); this.Panel1.Controls.Add(h); }
See the following for more info:
http://msdn.microsoft.com/en-us/library/20sx06fw.aspx
95463 Points
14106 Posts
Apr 23, 2012 02:13 PM|LINK
Put up a Repeater control with Hyperlink in it and then databind to List<string> then you will have this kind of behaviour..
thanks,
tparky
Member
112 Points
128 Posts
Multiple Hyperlink Buttons
Apr 23, 2012 01:21 PM|LINK
Hi Guys,
Here's something that someone could answer in their sleep. How do I from the code behind place multiple Hyperlink Buttons on a page with the same ID except the number is increasing by 1 each time. So for example:
<asp:hyperlink ID="File1" runat="server"/>
<asp:hyperlink ID="File2" runat="server"/>
<asp:hyperlink ID="File3" runat="server"/>
.......
Or how do I create Hyperlink buttons in the code behind with a ID and the render them to a panel?
Thanks guys for any Input that you can have on this.
Thomas Park
Programming in ASPX and C# build Application on Microsoft .NET Framework 4.0 for Small Business and Education
adeelehsan
All-Star
18265 Points
2731 Posts
Re: Multiple Hyperlink Buttons
Apr 23, 2012 01:27 PM|LINK
Use the following:
for (int i=1;i<=5;i++) { HyperLink h = new HyperLink(); //Set some other properties h.ID = "File"+i.ToString(); this.Panel1.Controls.Add(h); }See the following for more info:
http://msdn.microsoft.com/en-us/library/20sx06fw.aspx
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
ramiramilu
All-Star
95463 Points
14106 Posts
Re: Multiple Hyperlink Buttons
Apr 23, 2012 02:13 PM|LINK
Put up a Repeater control with Hyperlink in it and then databind to List<string> then you will have this kind of behaviour..
thanks,
JumpStart