单击动态创建的链接按钮时如何生成弹出的aspx窗口?

时间:2013-08-22 04:30:48

标签: c# asp.net

我创建了动态生成的链接按钮。我想在点击这些按钮时创建一个弹出窗口。如果可能的话。

   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);


 }

它显示错误“无法将字符串转换为空白”

1 个答案:

答案 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);
    }