protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
DisableFormat(ReportViewer1, "Pdf");
}
protected void DisableFormat(ReportViewer viewer, string formatName)
{
const System.Reflection.BindingFlags Flags =System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance;
System.Reflection.FieldInfo m_previewService = viewer.LocalReport.GetType().GetField("m_previewService", Flags);
System.Reflection.MethodInfo ListRenderingExtensions = m_previewService.FieldType.GetMethod("ListRenderingExtensions", Flags);
Object previewServiceInstance = m_previewService.GetValue(viewer.LocalReport);
IList extensions = (IList)ListRenderingExtensions.Invoke(previewServiceInstance, null); System.Reflection.PropertyInfo name = extensions[0].GetType().GetProperty("Name", Flags);
//Object extension;
foreach( Object extension in extensions)
{
if (String.Compare(name.GetValue(extension, null).ToString(), formatName, true) == 0 )
{
System.Reflection.FieldInfo m_isVisible = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
System.Reflection.FieldInfo m_isExposedExternally = extension.GetType().GetField("m_isExposedExternally", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
m_isVisible.SetValue(extension, false);
m_isExposedExternally.SetValue(extension, false) ;
break;
}
}
}
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.
The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.