<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
LinkButton link = new LinkButton();
link.Text = "Click"+i.ToString();
link.CommandName = i.ToString();
link.Command += new CommandEventHandler(click_command);
test1.Controls.Add(link);
}
}
void click_command(object sender, CommandEventArgs e)
{
msg.Text = "This is Link " + e.CommandName;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div id="test1" runat="server">
</div>
<asp:Literal ID="msg" runat="server"></asp:Literal>
</form>
</body>
</html>
执行-->查看源文件-->
<div id="test1">
<a href="javascript:__doPostBack('ctl02','')">Click0</a>
<a href="javascript:__doPostBack('ctl03','')">Click1</a>
<a href="javascript:__doPostBack('ctl04','')">Click2</a>
<a href="javascript:__doPostBack('ctl05','')">Click3</a></div>