Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. open new window from server side on button click

open new window from server side on button click

Scheduled Pinned Locked Moved ASP.NET
questionjavascripthtmlsysadmintools
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    For_IT
    wrote on last edited by
    #1

    Hi all, I would like to open new window on button click from sever side and write HTML content to it. I have written following code but this writes the HTML content to the main window instead of the new opened window.

    protected void btnClick_Click(object sender, EventArgs e)
    {
    Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">\n");
    Response.Write("window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800')");
    Response.Write("</script>");
    Response.Write("<html><head>");
    Response.Write("</head><body>");
    Response.Write("<div id='lnk' class='noprint' style='text-align:right'>");
    Response.Write("<a href='#' onclick='window.print();return false;'>Print</a>&nbsp");
    Response.Write("<a href='#' onclick='window.close();return false;'>Close</a>");
    Response.Write("</div>");
    Response.Write("<div id='printv' class='print'>");
    Response.Write("This is test");
    Response.Write("</div>");

    }
    

    can anyone please suggest me how can I achieve this? Thanks a lot.

    V 1 Reply Last reply
    0
    • F For_IT

      Hi all, I would like to open new window on button click from sever side and write HTML content to it. I have written following code but this writes the HTML content to the main window instead of the new opened window.

      protected void btnClick_Click(object sender, EventArgs e)
      {
      Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">\n");
      Response.Write("window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800')");
      Response.Write("</script>");
      Response.Write("<html><head>");
      Response.Write("</head><body>");
      Response.Write("<div id='lnk' class='noprint' style='text-align:right'>");
      Response.Write("<a href='#' onclick='window.print();return false;'>Print</a>&nbsp");
      Response.Write("<a href='#' onclick='window.close();return false;'>Close</a>");
      Response.Write("</div>");
      Response.Write("<div id='printv' class='print'>");
      Response.Write("This is test");
      Response.Write("</div>");

      }
      

      can anyone please suggest me how can I achieve this? Thanks a lot.

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      Check this out: function Clickheretoprint(){ var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=0"; var content_vlue = document.getElementById("print_content").innerHTML; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write(''); docprint.document.write(' '); docprint.document.write(' '); docprint.document.write(content_vlue); docprint.document.write(' '); docprint.document.write(' '); docprint.document.close(); docprint.focus(); } Source Courtesy: http://forum.java.sun.com/thread.jspa?threadID=5279919&messageID=10175156[^]

      Vasudevan Deepak Kumar Personal Homepage
      Tech Gossips
      A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups