|
| 1 | +--- |
| 2 | +title: Handle Upload Controls Visibility in TelerikPdfViewer |
| 3 | +description: Learn how to manage the visibility of upload controls in TelerikPdfViewer when loading a PDF file. |
| 4 | +type: how-to |
| 5 | +page_title: How to Control Upload Component Visibility in TelerikPdfViewer |
| 6 | +slug: pdfviewer-kb-upload-controls-visibility |
| 7 | +tags: pdfviewer, blazor, upload controls, visibility, enableloadercontainer |
| 8 | +res_type: kb |
| 9 | +ticketid: 1675214 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +<table> |
| 15 | + <tbody> |
| 16 | + <tr> |
| 17 | + <td>Product</td> |
| 18 | + <td>PdfViewer for Blazor</td> |
| 19 | + </tr> |
| 20 | + </tbody> |
| 21 | +</table> |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +When using the [TelerikPdfViewer](https://docs.telerik.com/blazor-ui/components/pdfviewer/overview) for Blazor, upload controls may still be visible while a PDF file is loading, even if the `EnableLoaderContainer` parameter is set to `false`. |
| 26 | + |
| 27 | +This knowledge base article also answers the following questions: |
| 28 | + |
| 29 | +- How to prevent interaction with Upload controls while a PDF is loading in TelerikPdfViewer? |
| 30 | +- How to hide Upload component in TelerikPdfViewer until the PDF file is fully loaded? |
| 31 | +- How to use custom CSS with TelerikPdfViewer to manage control visibility? |
| 32 | + |
| 33 | +## Solution |
| 34 | + |
| 35 | +To control the visibility of upload controls in the `TelerikPdfViewer` while a PDF is loading, apply custom CSS to hide the upload controls. This can be achieved by leveraging the [`OnOpen`](slug://components/pdfviewer/events#onopen) event to apply a CSS class with the required styles that hide the controls until the PDF file is loaded successfully. |
| 36 | + |
| 37 | +````RAZOR |
| 38 | +<TelerikPdfViewer Data="@PdfSource" |
| 39 | + Height="600px" |
| 40 | + EnableLoaderContainer="false" |
| 41 | + OnOpen="@OnPdfOpen" |
| 42 | + Class="@PdfClass"> |
| 43 | +</TelerikPdfViewer> |
| 44 | +<style> |
| 45 | + .my-pdf .k-external-dropzone { |
| 46 | + display: none; |
| 47 | + } |
| 48 | +
|
| 49 | + .my-pdf .k-upload { |
| 50 | + display: none; |
| 51 | + } |
| 52 | +</style> |
| 53 | +@code { |
| 54 | + private byte[] PdfSource { get; set; } |
| 55 | + private string PdfClass { get; set; } = ""; |
| 56 | +
|
| 57 | + private async Task OnPdfOpen(PdfViewerOpenEventArgs args) |
| 58 | + { |
| 59 | + //hide upload controls |
| 60 | + PdfClass = "my-pdf"; |
| 61 | + } |
| 62 | +
|
| 63 | + protected override void OnInitialized() |
| 64 | + { |
| 65 | + base.OnInitialized(); |
| 66 | + } |
| 67 | +} |
| 68 | +```` |
| 69 | + |
| 70 | +## See Also |
| 71 | + |
| 72 | +- [TelerikPdfViewer Overview](slug://components/pdfviewer/overview) |
| 73 | +- [TelerikPdfViewer Events](slug://components/pdfviewer/events) |
0 commit comments