Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET HTML C#4.0 , +
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 19:49pm
Edited 17-Nov-12 2:00am
v2
Comments
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
good
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 = "www.google.com";
            htmlAnchor.InnerText = "Click";
            divTest.Controls.Add(htmlAnchor);
  Permalink  
Comments
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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2014
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