0
4

2 回答 2

3

用户 LinkBut​​ton 使链接看起来像一个超链接,但行为像一个按钮。这是你的答案

int counter = 1;
foreach (Node node in this._nodes)
{
    LinkButton lnkPost = new LinkButton();
    lnkPost.ID = "lnk" + i.ToString();
    lnkPost.Text = node.Title;
    lnkPost.Click += new EventHandler(LinkPost_OnClick);

    parent.Controls.Add(lnkPost);
}

protected void LinkPost_OnClick(object sender, EventArgs e)
{
    //add your handler code here
}
于 2012-06-25T11:11:38.663 回答
1

大致是这样的:

int counter = 1;
foreach (Node node in this._nodes)
{
 HyperLink DynLink = new HyperLink();         
 DynLink.ID = "DynLink" + counter.ToString();         
 DynLink.Text = node.title;            
 DynLink.NavigateUrl = "MyLink";  
 counter++;
}
于 2012-06-25T11:05:57.963 回答