Create Dynamic hyperlink using C#
To create a dynamic hyperlink using c# code behind, this blog will be very useful.
here 'attach' is a string array with the collection of urls.
just pass this string array to this loop to create dynamic hyperlinks in a very simple way.
string text = string.Empty;
int count = attach.Length;
for (int i = 0; i < count; i++)
{
int index = attach[i].LastIndexOf("/");
text = attach[i].Substring(index + 1);
HyperLink hy = new HyperLink();
hy.ID = Convert.ToString(i + 1);
hy.Text = text;
hy.Target = "_blank";
hy.CssClass = "attach1";
hy.ToolTip = attach[i].ToString();
hy.NavigateUrl = "~/"+attach[i].ToString();
link_div.Controls.Add(hy);
//link_div.Controls.Add(new LiteralControl(" "));
link_div.Controls.Add(new LiteralControl("\t"));
}
here is the code using javascript. http://kannanmk.blogspot.com/2009/05/how-to-create-dynamic-hyperlink-in.html
No comments:
Post a Comment