The code below is acting up and I am not sure what to do to fix it.
In my form, I have 3 buttons... 1. Upload File 2. Disabled Button 3. ViewPDF
When site is launch (MainPage), I clik on "Upload File" which is opens up a modal form. I can close this modal form and get back to MainPage.
Now on MainPage I click on "ViewPDF, it opens up PDF in a new Tab and I can close this PDF tab normally. So far, all is OK.
Now I click on "Upload File" which is opens up the modal form. When I close this modal form, it closes but opens up the PDF file that was opened previously.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
12 Points
89 Posts
PDF File Viewer Opens Up by itself
Jul 16, 2020 05:57 AM|njehan01|LINK
The code below is acting up and I am not sure what to do to fix it.
In my form, I have 3 buttons... 1. Upload File 2. Disabled Button 3. ViewPDF
When site is launch (MainPage), I clik on "Upload File" which is opens up a modal form. I can close this modal form and get back to MainPage.
Now on MainPage I click on "ViewPDF, it opens up PDF in a new Tab and I can close this PDF tab normally. So far, all is OK.
Now I click on "Upload File" which is opens up the modal form. When I close this modal form, it closes but opens up the PDF file that was opened previously.
Contributor
3730 Points
1431 Posts
Re: PDF File Viewer Opens Up by itself
Jul 16, 2020 07:30 AM|yij sun|LINK
Hi njehan01,
Accroding to your description and codes, I have create a test and works fine.I couldn't reproduce your problems.
Could you post your full codes about the "Upload File" button to us?It will help us to solve your problem.
My codes:
Code-behind:
Best regards,
Yijing Sun
Member
12 Points
89 Posts
Re: PDF File Viewer Opens Up by itself
Jul 16, 2020 02:22 PM|njehan01|LINK
Hi,
Here is the code for button "Upload File":
Contributor
3730 Points
1431 Posts
Re: PDF File Viewer Opens Up by itself
Jul 17, 2020 07:00 AM|yij sun|LINK
Hi njehan01,
Accroding to your description,as far as I think,your problem is window.location.reload().The original page is reloaded.
So,I suggest you could use hide the dialog replace window.location.reload().
More details,you could refer to below codes:
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" /> <script> $(function () { $("#Button1").click(function (event) { event.preventDefault(); opendialog2("http://localhost:50186/MyUploder.aspx"); }) function opendialog2(page) { var $dialog = $('#somediv') .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>') .dialog({ title: "Upload Files", autoOpen: false, dialogClass: 'dialog_fixed,ui-widget-header', modal: true, height: 600, width: 1000, minWidth: 400, minHeight: 400, draggable: true, close: function (ev, ui) { $(this).hide(); }, buttons: { "Ok": function () { $(this).dialog("close"); } } }); $dialog.dialog('open'); } }) </script> <div> <asp:Button ID="Button1" runat="server" Text="Upload Files" BackColor="#990000" Font-Bold="True" Font-Size="Large" ForeColor="Yellow" /> </div> <div id="somediv"></div> <div class="container-fluid"> <div class="first"> <div class="row"> <div class="col-lg-4"> <div id="div1" class="st-box" runat="server"> <button id="Button2" class="button; disabled" runat="server" style="enabled=false; vertical-align: middle; width: 100%"> <span id="spanButton1" runat="server">Disabled Button</span> </button> <p> This is my paragraph </p> <center> <button id="Button7" class="button" runat="server" style="vertical-align:middle; width:35%" onserverclick="ViewPDF"><span id="span1" runat="server" >Load PDF File</span></button> </center> </div> </div> </div> </div> </div>
Result:
Best regards,
Yijing Sun
Member
12 Points
89 Posts
Re: PDF File Viewer Opens Up by itself
Jul 17, 2020 03:21 PM|njehan01|LINK
it worked, thanks