Click here to Skip to main content
11,813,557 members (43,787 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET HTML C#4.0 ASP.NET4 , +
HI every one.

In my Project I need To Assign String value to a anchor tag ...

For Each String value i need to Dynamically create a New Anchor Tag in cs file ..

can anyone help me pls
Posted 16-Nov-12 18:49pm
Edited 17-Nov-12 1:00am
Krunal R at 17-Nov-12 2:07am
what have you tried so far ?
Hari Chandra Prasad Ravuri at 17-Nov-12 2:08am
hi bro till now i tried this but it didnt work
int i = 1;
Fileattach = At;
if (Fileattach != "")
HtmlAnchor HA = new HtmlAnchor();
HA.Visible = true;
HA.ID = "ID" + i.ToString();
HA.Attributes.Add("runat", "server");
HA.InnerHtml = Fileattach.ToString();
HA.HRef = "./Download.aspx?File=" + Fileattach;
n.podbielski at 17-Nov-12 6:34am
Please edit your question to be more clear. For now I read this 3 times and still don't get it.
Hari Chandra Prasad Ravuri at 17-Nov-12 7:01am
check now i have edited my question
Pro Idiot at 18-Nov-12 1:59am
Posted a solution , Do check

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Add a div in your aspx , in which you want to add all your anchor tags

<div id="divTest" runat="server"></div>

Code , to add an anchor Tag to the Div

HtmlAnchor htmlAnchor = new HtmlAnchor();
          htmlAnchor.HRef = "";
          htmlAnchor.InnerText = "Click";
Hari Chandra Prasad Ravuri at 18-Nov-12 23:41pm
Thanks Deepak i will try it
Pro Idiot at 19-Nov-12 11:24am
If it helped, please mark as answer :)
Hari Chandra Prasad Ravuri at 20-Nov-12 0:00am
Once again thanks depaak it worked for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Abhinav S 275
1 Palash Mondal_ 190
2 KrunalRohit 150
4 Manas_Kumar 115
0 OriginalGriff 3,877
1 KrunalRohit 2,526
2 Maciej Los 2,245
3 CPallini 2,240
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100