我创建了动态生成的链接按钮。我想在点击这些按钮时创建一个弹出窗口。如果可能的话。
foreach (string fileName in allFiles)
{
// now create the LinkButtons ...
Panel1.Controls.Add(new LiteralControl("<div>"));
LinkButton lb = new LinkButton();
lb.Text = fileName;
lb.ID = fileName;
Session["fn"] = fileName;
Panel1.Controls.Add(lb);
Panel1.Controls.Add(new LiteralControl("</div>"));
lb.PostBackUrl = ScriptManager.RegisterStartupScript(Page, typeof(Page), "New", "window.open('pdf_files.aspx');", true);
}
它显示错误“无法将字符串转换为空白”
答案 0 :(得分:0)
将lb.PostBackUrl
更改为lb.OnClick
试试这个
lb.**OnClick** += Clickedevent
private void Clickedevent (object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "New", "window.open('pdf_files.aspx');", true);
}