Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Monday, September 5, 2016

javascript sample from aspx.cs page


Printing from aspx.cs page

imgBtnPrint.Attributes.Add("onclick", "window.print();");

alert box from aspx.cs page

Response.Write("<script>alert('Hello');</script>");
button that directly prints a document via website:

<input type="button" value="Print" onclick="window.print();" />

or

<asp:button id="button1" runat="server" onclientclick="window.print(); return false;" text=Print" />

Another sample
  string popupScript = "<script language='javascript'>" + "window.open('frmLogin.aspx" + "', 'PasswwordExpiryWarning', " + "'width=430, height=318, menubar=no, resizable=no')" + "</script>";
 ClientScript.RegisterStartupScript(popupScript.GetType(), "Warning", popupScript);



btn cancle (on popup window):
btnCancel.Attributes.Add("onClick", "javascript:window.close();");