FAQ/implement-fully-qualified-hidden-filters.md
... ...
@@ -1,6 +1,72 @@
1
-#Implement Fully Qualified Hidden Filters
1
+#Hiding Report Viewer Buttons
2
+
3
+##Question
4
+
5
+How do I hide toolbar buttons on the Report Viewer via the code-behind file?
6
+
7
+##Answer
8
+
9
+For most toolbar buttons, we strongly recommend enabling/disabling them in the InitializeReporting() method of your global.asax. There are a multitude of settings specifically for enabling/disabling common buttons.
10
+
11
+If you still believe you must do this in the code behind file for the report viewer page, you can access the [[AdHocSettings|/API/AdHocSettings]] properties from the code behind file on the page.
12
+
13
+If you cannot find a setting for the button in question, then you can directly modify the ReportViewer-Body.ascx file to make the button you need to modify a server control. For example, if you want to hide the "Print" options on the page, you will need to modify the following:
14
+
15
+```html
16
+ <div class="btn-group cool"> <!--Change this div to use runat="server" and id="ddlPrintReportSet"-->
17
+ <button type="button" class="btn" lang-title="js_Print" title="Print"
18
+ onclick="responseServer.OpenUrl('rs.aspx?p=htmlreport&print=1', 'aspnetForm', '');">
19
+ <img class="icon" src="rs.aspx?image=ModernImages.print.png" alt="Printer" />
20
+ <span class="hide" lang-text="js_Print">Print</span>
21
+ </button>
22
+ <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
23
+ <span class="caret"></span>
24
+ </button>
25
+ <ul class="dropdown-menu">
26
+ <li><a href="javascript:void(0)" title="" style="min-width: 18em;"
27
+ onclick="responseServer.OpenUrl('rs.aspx?p=htmlreport&print=1', 'aspnetForm', '');">
28
+ <img class="icon" src="rs.aspx?image=ModernImages.print-32.png" alt="" />
29
+ <b lang-text="js_PrintHTML">Print HTML</b><br>
30
+ <span lang-text="js_PrintDirectlyMessage">Print directly from your browser, the fastest way for modern browsers</span>
31
+ </a></li>
32
+ <li><a href="javascript:void(0)" title="" onclick="responseServer.OpenUrlWithModalDialogNewCustomRsUrl('rs.aspx?output=PDF', 'aspnetForm', 'reportFrame', nrvConfig.ResponseServerUrl);">
33
+ <img class="icon" src="rs.aspx?image=ModernImages.html-to-pdf-32.png" alt="" />
34
+ <b lang-text="js_HTML2PDF">HTML-powered PDF</b><br>
35
+ <span lang-text="js_HTML2PDFMessage">One-file compilation of all the report's pages</span>
36
+ </a></li>
37
+ </ul>
38
+ </div>
39
+```
40
+
41
+In our latest distributions, the controls are all client side. You will want to add a **runat="server"** tag to all the elements you want to access in your code behind.
42
+
43
+Next, you will want to add a code file to **ReportViewer-Body.ascx**. This can be done either by Visual Studio or by navigating to the folder where **ReportViewer-Body.ascx** is located and add the file **ReportViewer-Body.ascx.cs** to the directory.
44
+
45
+Open the file and edit its contents to the following:
2 46
3
-The correct global code is:
4 47
```csharp
5
-AdHocSettings.HiddenFilters["schema.tablename.columnname"] = new string[3] { "value1", "value2", "value3" };
48
+using System;
49
+using System.Collections.Generic;
50
+using System.Web;
51
+using System.Web.UI;
52
+using System.Web.UI.WebControls;
53
+using Izenda.AdHoc;
54
+
55
+public partial class Resources_Html_ReportViewer_Body : UserControl {
56
+ protected void Page_Load(object sender, System.EventArgs e) {
57
+ ddlPrintReportSet.Visible = false;
58
+ }
59
+}
6 60
```
61
+
62
+You will then need to change one more line in your **ReportViewer.ascx** file. It is the top server tag declaration.
63
+
64
+```html
65
+<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ReportViewer-Body.ascx.cs" Inherits="Resources_Html_ReportViewer_Body" %>
66
+```
67
+
68
+Now when restart your web site, the newly implemented code should take into effect and you will not see the print options dropdown menu in the report viewer. You can modify this code sample to suit your individual needs.
69
+
70
+**Troubleshooting**
71
+
72
+If you are having problems getting Visual Studio to recognize your wireup to the code file you created, try closing and re-opening Visual Studio. This will refresh the website wiring and force it to recognize your new code file.
... ...
\ No newline at end of file