简体   繁体   中英

how to generate a pop up aspx window when clicking on the dynamically created link button?

I have created dynamically generated link button. I wants to create a pop up window when clicking on these buttons.how is it possible.

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


 }

it shows an error "cant convert string to void "

Change lb.PostBackUrl to lb.OnClick

try this

lb.**OnClick** += Clickedevent













private void Clickedevent (object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "New", "window.open('pdf_files.aspx');", true);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM