1.11M Members

generate anchor tag dynamically in code behind

 
0
 

Hi,

I want to generate an anchor tag

<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>

in code behind using c#...but dunno how to do....

 
0
 

Add the namespace for HtmlAnchor (using System.Web.UI.HtmlControls;),

protected void Page_Load(object sender, EventArgs e)
    {
        HtmlAnchor htmlanchor = new HtmlAnchor();
        htmlanchor.HRef = "#";
        htmlanchor.Title = "Welcome"; //tooltip
        htmlanchor.InnerText = "Welcome";
        this.form1.Controls.Add(htmlanchor);
    }
 
0
 

Thanks Renu

Question Answered as of 4 Years Ago by Renukavani
 
0
 

And how do you associate it with an image?

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: