Displaying image and hyperlink using stringbuilder

hie

how can i display an image using the stringbuilder.what syntax do i use

also how do i make a hyperlink created using a strinh builder clickable

thanks

tawand

Even if you decided to use a stringbuilder for this purpose, you’d still have to output this to a screen?

I take it you are doing something like this in your code behind:

    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("<a href=\\"http://www.mypage.com\\"><img src=\\"bla.jpg\\" /></a>");
    spanBla.InnerText = sb.ToString();

And in your aspx code you have <span id=“spanBla” runat=“server” />

Why do yo need to use the StringBuilder?



string myLink = string.Format(@"<a href='{0}' title='this is cool' >{1}</a>", @"http://www.yahoo.com", @"Yahoo!");


thanks for the response guys

the only problem is i am getting the image url from a datareader object

i am using vb.net not php.

Is there a way of displaying data about a single item without using the stringbuilder in vb.net 2003

thanks

It’s not php, it’s C#.


            while (reader.Read())
            {
                reader["URL"].ToString();
                reader["LinkName"].ToString();
            }


I also add you really should be using databinding, not stringbuilders and such.

Something like:


<a href='<&#37;# DataBinder.Eval(Container.DataItem, "Url") %>'><%# DataBinder.Eval(Container.DataItem, "LinkName") %></a>

BTW, the reason he is using the PHP bbcode tag is that it works for syntax highlighting on C# as well.

Thanks a lot guys

that did it for me