Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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
Updated 17-Nov-12 1:00am
v2
Comments
[no name] 17-Nov-12 2:07am    
what have you tried so far ?
Hari Chandra Prasad Ravuri 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 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 17-Nov-12 7:01am    
check now i have edited my question
Pro Idiot 18-Nov-12 1:59am    
Posted a solution , Do check

1 solution

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

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


Code , to add an anchor Tag to the Div

HtmlAnchor htmlAnchor = new HtmlAnchor();
          htmlAnchor.HRef = "www.google.com";
          htmlAnchor.InnerText = "Click";
          divTest.Controls.Add(htmlAnchor);
 
Share this answer
 
Comments
Hari Chandra Prasad Ravuri 18-Nov-12 23:41pm    
Thanks Deepak i will try it
Pro Idiot 19-Nov-12 11:24am    
If it helped, please mark as answer :)
Hari Chandra Prasad Ravuri 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900