如何动态地创建ASP.NET新的超链接?超链接、动态、ASP、NET

2023-09-03 01:40:54 作者:别理我√我有病

我会解释我想要实现的:

I'll explain what I'm trying to achieve:

我想有一个情况,因为我想在后面的code循环创造他们,我可以创造尽可能多的控制。我可以在使用PHP,通过混合PHP code和HTML code做到这一点。这使我动态生成实际的HTML标签。

I want to have a situation where I can create as many controls as I want by creating them in a loop in the code behind. I can do this while using PHP, by mixing the PHP code and the HTML code. This allows me to generate actual HTML tags dynamically.

在ASP.NET中,我还没有找到一种方法来复制此功能。

In ASP.NET, I haven't found a way to replicate this functionality.

我想过使用一个循环,在code背后是这样的init()函数来创建新的()对象的数组,设置其属性,并希望它传递到aspx文件,但它没有工作。

I've thought about using a loop in the code behind on something like the Init() function to create an array of new() objects, setting their attributes and hoping it is passed into the aspx file, but it didn't work.

我如何做到这一点?

推荐答案

如果你想创造动态ASP.Net超链接控制 你可以简单地做到这一点:

If you want to creat Dynamically ASP.Net Hyperlink control You can simply do this:

HyperLink hyp = new HyperLink();
    hyp.ID = "hypABD";
    hyp.NavigateUrl = "";
    Page.Controls.Add(hyp);