asp.net中用AJAX实现折叠菜单(Accordion控件),但是HyperLink跳转页面不起作用,急啊。。。
public void Display()
{
string sql = "select * from contenttree where upID=3109";
DataTable dt = DataSet(sql).Tables[0];
foreach (DataRow dr in dt.Rows)
{
AccordionPane ap = new AccordionPane();
Label lblMouth = new Label();
string head = Server.HtmlDecode("<table width='173' height='35' border='0' cellpadding='0' cellspacing='0'><tr><td align='right' background='images/hj_14.jpg'><table width='75%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center' class='h1'>" + Convert.ToString(dr["NodeName"]) + "</td></tr></table></td></tr></table>");
lblMouth.Text = head;
ap.HeaderContainer.Controls.Add(lblMouth);
int id = Convert.ToInt32(dr["ID"]);
string sql2 = string.Format("select * from contenttree where upID={0}", id);
DataTable dt2 = DataSet(sql2).Tables[0];
foreach (DataRow dr2 in dt2.Rows)
{
int id2 = Convert.ToInt32(dr2["ID"]);
HyperLink hl = new HyperLink();
string content = Server.HtmlDecode("<table width='85%' border='0' cellspacing='0' cellpadding='0'><tr><td width='20' align='left'><img src='images/hj_10.jpg' width='20' height='9' /></td><td align='left' class='h3'>" + Convert.ToString(dr2["NodeName"]) + "</td></tr></table>");
hl.Text = content;
hl.NavigateUrl = string.Format("~/Front/cxzx/hjmd.aspx?id={0}", id2);
ap.ContentContainer.Controls.Add(hl);
}
Accordion1.Panes.Add(ap);
}
}
追问:你这是改了个啥啊?
答案:那就不要用HyperLink嘛
改成:
string content = Server.HtmlDecode("<table width='85%' border='0' cellspacing='0' cellpadding='0'><tr onclick=\"location.href='/Front/cxzx/hjmd.aspx?id="+id2+"';\"><td width='20' align='left'><img src='images/hj_10.jpg' width='20' height='9' /></td><td align='left' class='h3'>" + Convert.ToString(dr2["NodeName"]) + "</td></tr></table>");
上一个:asp.net RadioButtonList问题,请问为什么每次选择无论选择什么都是数字1呢?
下一个:如何在ASP.NET程序中插入一个本地图片,用Image控件,设置ImageUrl选择本地图片,在aspx中不显示