0

How to add JavaScript function window.print()in C# code.

C# snippet :

private void CTRL3_5_Clicked(object sender, ClickedEventArgs e)
    {
        //JavaScript function here!
    }

closed as off-topic by Benny Skogberg Dec 22 '15 at 8:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to SharePoint are off-topic here, but can be asked on Stack Overflow." – Benny Skogberg
If this question can be reworded to fit the rules in the help center, please edit the question.

1
  • Right Click on your solution
  • Click Add Reference In the new popup window Type 'System.Web" in the search box.
  • You will get the result System.Web.
  • Click on CheckBox against it.
  • Click Okay

enter image description here

Add reference to

using System.Web.UI;

private void CTRL3_5_Clicked(object sender, ClickedEventArgs e)
    {
        //JavaScript function here!
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                           "Print", "window.print();", true);
    }
  • I am getting the following error: ScriptManager does not exist in current context – Nderon Hyseni Dec 22 '15 at 8:06
  • 1
    add reference to using System.Web.UI; – Gaurravs Dec 22 '15 at 8:08
  • I cant find it in references it is missing can i add it manually? – Nderon Hyseni Dec 22 '15 at 8:11
  • yes you can add it manually – Gaurravs Dec 22 '15 at 8:14
  • but i cannot find it I am missing it i don not know how to add it? – Nderon Hyseni Dec 22 '15 at 8:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.