Hi Ben
This is exactly what we mean by writing ASPNET Rendered
Controls. You can write your own control in ASPNET. Ok
here goes the logic, but before I start, I assume you are
a bit familiar with HTML and C#.
All you need to do is to first create a string which
stores HTML data equivalent to the 100 hyperlinks that
you wanna create, and then render this string on a HTML
Label. Find attached the sample code(not tested).
public class HyperlinkArray :
System.Web.UI.WebControls.Label
{
public HyperlinkArray()
{
//
// TODO: Add constructor logic
here
//
}
public System.Data.DataTable LabelData;
protected override void OnPreRender
(EventArgs e)
{
HttpWriter htp = new HttpWriter();
htp.Write(FormHtmlString());
base.OnPreRender (e);
}
private string FormHtmlString()
{
string s = "";
for(int i = 0;
i<LabelData.Columns.Count; i++)
{
s += "<a href=" +
LabelData.Rows[i]["Hyperlink"].ToString();
s += "
CSSclass=\"HyperLinkClass\" >";
s += ">" + LabelData.Rows
[i]["HyperlinkText"].ToString();
s += "</a>";
}
return s;
}
}
Hope this helps...
Ramjee
>-----Original Message-----
>Hi,
[quoted text clipped - 7 lines]
> for (int i =0 ; i < measureArray.Count; i++)
> {
</script>
><td>
> <asp:Label ID=measureArray[i].Name text=measureArray[i].Value />
[quoted text clipped - 12 lines]
>
>.
Benjamin Ong - 23 Feb 2005 15:48 GMT
Hi Ramjee,
Thanks for the reply to my message. While I was waiting for posts I
came up with another method of dynamically generating web controls in
ASP.NET. I did some research and found out that by using the
placeholder web control I could generate any number of Web controls
dynamically. I haven't had a chance to try your solution yet but I was
wondering if you had any experience using the place holder web control,
and if so which solution should be used and why.
Thanks,
Ben